httpauth

package
v0.0.0-...-73b9a49 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDIDFromContext

func GetDIDFromContext(ctx context.Context) (string, error)

Types

type AccessController

type AccessController struct {
	// contains filtered or unexported fields
}

func NewAccessController

func NewAccessController(subjects Subjects, policies Policies) (*AccessController, error)

func (*AccessController) Authorize

func (acl *AccessController) Authorize(next http.Handler) http.Handler

type CtxKey

type CtxKey string
const (
	CtxKeySubject  CtxKey = "subject"
	CtxKeyJWT      CtxKey = "token"
	CtxKeyDIDClaim CtxKey = "did"
)

type JWTAuthenticator

type JWTAuthenticator struct {
	// contains filtered or unexported fields
}

func NewJWTAuthenticatorFromJWKSURL

func NewJWTAuthenticatorFromJWKSURL(jwksURL url.URL, updatePeriod time.Duration) (*JWTAuthenticator, error)

func (*JWTAuthenticator) Authenticate

func (authn *JWTAuthenticator) Authenticate(next http.Handler) http.Handler

func (*JWTAuthenticator) Stop

func (authn *JWTAuthenticator) Stop()

type Policies

type Policies interface {
	SetPolicy(ctx context.Context, policy Policy) error
	GetAllPolicies(ctx context.Context) ([]Policy, error)
}

type Policy

type Policy struct {
	Role    string
	Path    string
	Methods []string
}

type Subject

type Subject struct {
	DID        string
	Role       string
	Disabled   bool
	Attributes map[string]string
}

type Subjects

type Subjects interface {
	SetSubject(ctx context.Context, subject Subject) error
	GetSubjectByDID(ctx context.Context, did string) (Subject, error)
	GetSubjectsByAttribute(ctx context.Context, attributeKey, attributeValue string) ([]Subject, error)
	DeleteSubjectByDID(ctx context.Context, did string) error
}

Jump to

Keyboard shortcuts

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