Documentation
¶
Overview ¶
Package authrpc provides fail-closed jsonrpc authorization middleware.
Index ¶
Constants ¶
View Source
const CodeForbidden = -32001
Variables ¶
View Source
var ( ErrNilAuthorizer = errors.New("JSON-RPC authorization authorizer is nil") ErrNilRequestMapper = errors.New("JSON-RPC authorization request mapper is nil") )
Functions ¶
func DecisionFromContext ¶
func DecisionFromContext(ctx context.Context) (authorization.Decision, bool)
func NewMiddleware ¶
func NewMiddleware( authorizer Authorizer, mapper RequestMapper, middlewareOptions ...Option, ) (jsonrpc.Middleware, error)
Types ¶
type Authorizer ¶
type Authorizer interface {
Decide(context.Context, authorization.Request) (authorization.Decision, error)
}
type DeniedError ¶
type DeniedError func(authorization.Decision) *jsonrpc.Error
type ErrorMapper ¶
type Option ¶
type Option func(*options)
func WithDeniedError ¶
func WithDeniedError(mapper DeniedError) Option
func WithErrorMapper ¶
func WithErrorMapper(mapper ErrorMapper) Option
type RequestMapper ¶
type RequestMapper func(context.Context, json.RawMessage) (authorization.Request, error)
Click to show internal directories.
Click to hide internal directories.