jwt

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithToken

func CtxWithToken(ctx context.Context, token string) context.Context

func SubjectFromToken

func SubjectFromToken(token string) (string, bool)

Types

type AuthArgs

type AuthArgs struct {
	URI    *regexp.Regexp
	Scopes []*regexp.Regexp
}

type ClaimsFunc

type ClaimsFunc = func(ctx context.Context, method, uri string) jwt.ClaimsValidator

func MakeClaimsFunc

func MakeClaimsFunc(methods map[string][]AuthArgs) ClaimsFunc

type DeniedClaimsError

type DeniedClaimsError struct {
	jwt.MapClaims
	Err error
}

func (DeniedClaimsError) Error

func (c DeniedClaimsError) Error() string

func (DeniedClaimsError) Unwrap

func (c DeniedClaimsError) Unwrap() error

func (DeniedClaimsError) Validate

func (c DeniedClaimsError) Validate() error

type Interceptor

type Interceptor = func(ctx context.Context, method, uri string) (context.Context, error)

func NewInterceptorWithValidator

func NewInterceptorWithValidator(validator Validator, auths map[string][]AuthArgs, whiteList ...RequestMatcher) Interceptor

NewInterceptor authorizes HTTP request with validator.

type RequestMatcher

type RequestMatcher struct {
	Method string
	URI    *regexp.Regexp
}

RequestMatcher allows request without token validation.

type Validator

type Validator interface {
	ParseWithClaims(ctx context.Context, token string, claims jwt.Claims) error
}

Jump to

Keyboard shortcuts

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