jwt

package
v2.25.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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