Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTMiddleware ¶
func JWTMiddleware(config JWTMiddlewareConfig) func(http.Handler) http.Handler
JWTMiddleware creates an HTTP middleware that parses JWTs and attaches the User to the context.
func UserFromContext ¶
UserFromContext retrieves the user from the context.
Types ¶
type JWTMiddlewareConfig ¶
type JWTMiddlewareConfig struct {
// SecretKey is used to verify the JWT signature.
SecretKey []byte
// Strict determines if requests without a valid token are rejected.
// If false, invalid or missing tokens just mean no User is attached to context.
Strict bool
}
JWTMiddlewareConfig holds configuration for the JWT middleware.
Click to show internal directories.
Click to hide internal directories.