middleware

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const APITokenPrefix = "it."

Variables

View Source
var (
	ErrNoToken         = errors.New("no authentication token")
	ErrInvalidAPIToken = errors.New("invalid API token")
	ErrTokenRejected   = errors.New("authentication token has been rejected")
	ErrTokenExpired    = errors.New("token has expired")
)

Functions

func AuthenticateRequest

func AuthenticateRequest(cfg config.Config, ds *repo.Queries, req *http.Request) (*jwt.Claims, error)

func ClaimsFromContext

func ClaimsFromContext(ctx context.Context) *jwt.Claims

ClaimsFromContext returns the JWT claims associated with ctx.

func ContextWithClaims

func ContextWithClaims(ctx context.Context, claims *jwt.Claims) context.Context

ContextWithClaims returns a new context.Context with claims attached. Use ClaimsFromContext to retrieve the claims.

func ContextWithToken

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

func FindCookie

func FindCookie(cookieName string, headers http.Header) *http.Cookie

func NewAuthInterceptor

func NewAuthInterceptor(registry *protoregistry.Files) connect.UnaryInterceptorFunc

func NewErrorInterceptor

func NewErrorInterceptor() connect.UnaryInterceptorFunc

func NewJWTMiddleware

func NewJWTMiddleware(cfg config.Config, repo *repo.Queries, next http.Handler, skipVerifyFunc func(r *http.Request) bool) http.HandlerFunc

func TokenFromContext

func TokenFromContext(ctx context.Context) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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