authorization

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAuthenticationMiddleware = errors.New("unable to extract user id from context, missing authentication middleware?")
)

Functions

This section is empty.

Types

type ActionResourcePolicy

type ActionResourcePolicy struct {
	Action            string
	ResourceExtractor ResourceExtractor
}

func (ActionResourcePolicy) Authorize

func (p ActionResourcePolicy) Authorize(ctx context.Context, userID string, authorizer AuthorizerClient, r *http.Request) error

type AuthorizerClient

type AuthorizerClient interface {
	IsAuthorizedWithReasonWithContext(ctx context.Context, userID, action string, resource *proto.Origin) (bool, string, error)
}

type Middleware

type Middleware struct {
	Tracer middleware.Tracer
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Middleware

func (*Middleware) Middleware

func (m *Middleware) Middleware() func(http.Handler) http.Handler

func (*Middleware) SetPolicy

func (m *Middleware) SetPolicy(route *mux.Route, policy Policy) *Middleware

type MultiPolicy

type MultiPolicy []Policy

func (MultiPolicy) Authorize

func (policies MultiPolicy) Authorize(ctx context.Context, userID string, authorizer AuthorizerClient, r *http.Request) error

type Option

type Option func(*Middleware)

func WithAuthorizerClient

func WithAuthorizerClient(client AuthorizerClient) Option

type Policy

type Policy interface {
	Authorize(ctx context.Context, userID string, authorizer AuthorizerClient, r *http.Request) error
}

type ResourceExtractor

type ResourceExtractor func(ctx context.Context, r *http.Request) (*proto.Origin, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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