Documentation
¶
Index ¶
- Constants
- func CallerIdentityFromRequest(ctx context.Context, r *http.Request) (string, error)
- func GetIdentityFromContext(ctx context.Context, identityClaim string) (string, error)
- func GetJWTIssuerConfigFromContext(ctx context.Context) (config.JWTIssuerConfig, bool)
- func GetJWTTokenFromContext(ctx context.Context) *jwt.Token
- func GetUsernameFromContext(ctx context.Context) string
- func SetJWTIssuerConfigContext(ctx context.Context, cfg config.JWTIssuerConfig) context.Context
- func SetJWTTokenContext(ctx context.Context, token *jwt.Token) context.Context
- func SetUsernameContext(ctx context.Context, username string) context.Context
- type CallerIdentityMiddleware
- type JWTHandler
- type JWTHandlerConfig
- type Payload
Constants ¶
const ( ContextUsernameKey contextKey = "username" ContextJWTTokenKey contextKey = "jwt_token" ContextJWTIssuerConfigKey contextKey = "jwt_issuer_config" )
Variables ¶
This section is empty.
Functions ¶
func CallerIdentityFromRequest ¶ added in v0.3.0
CallerIdentityFromRequest resolves the caller identity. Priority: identity header (per-issuer, if configured and present) > JWT claim from matched issuer config. The issuer config is set in context by JWTHandler when a token is validated.
func GetIdentityFromContext ¶ added in v0.3.0
GetIdentityFromContext returns the configured JWT claim value used as the request identity.
func GetJWTIssuerConfigFromContext ¶ added in v0.3.1
func GetJWTIssuerConfigFromContext(ctx context.Context) (config.JWTIssuerConfig, bool)
func GetJWTTokenFromContext ¶ added in v0.3.0
func GetUsernameFromContext ¶
func SetJWTIssuerConfigContext ¶ added in v0.3.1
func SetJWTTokenContext ¶ added in v0.3.0
Types ¶
type CallerIdentityMiddleware ¶ added in v0.3.0
CallerIdentityMiddleware resolves and attaches the caller identity used for audit fields.
func NewCallerIdentityMiddleware ¶ added in v0.3.0
func NewCallerIdentityMiddleware() CallerIdentityMiddleware
type JWTHandler ¶ added in v0.3.0
type JWTHandler struct {
// contains filtered or unexported fields
}
JWTHandler validates JWT tokens on incoming requests. Call Close() during shutdown to stop the background JWKS refresh goroutine.
func NewJWTHandler ¶ added in v0.3.0
func NewJWTHandler(ctx context.Context, cfg JWTHandlerConfig) (*JWTHandler, error)
func (*JWTHandler) Close ¶ added in v0.3.0
func (h *JWTHandler) Close()
func (*JWTHandler) Middleware ¶ added in v0.3.1
func (h *JWTHandler) Middleware(next http.Handler) http.Handler
Middleware returns a standard HTTP middleware that validates JWT tokens. Requests with a valid token proceed to next with claims in context; requests without valid credentials receive a 401 response.
type JWTHandlerConfig ¶ added in v0.3.0
type JWTHandlerConfig struct {
Issuers []config.JWTIssuerConfig
}