authrpc

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 5 Imported by: 0

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 ErrorMapper func(error) *jsonrpc.Error

type Option

type Option func(*options)

func WithDeniedError

func WithDeniedError(mapper DeniedError) Option

func WithErrorMapper

func WithErrorMapper(mapper ErrorMapper) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL