{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package auth\n\n## Constants\n\n```go\nconst (\n\tContextUsernameKey        contextKey = \"username\"\n\tContextJWTTokenKey        contextKey = \"jwt_token\"\n\tContextJWTIssuerConfigKey contextKey = \"jwt_issuer_config\"\n)\n```\n\n## Functions\n\n```go\nfunc CallerIdentityFromRequest(ctx context.Context, r *http.Request) (string, error)\n```\nCallerIdentityFromRequest resolves the caller identity. Priority: identity header (per-issuer, if configured and present) \u003e JWT claim from matched issuer config. The issuer config is set in context by JWTHandler when a token is validated.\n\n```go\nfunc GetIdentityFromContext(ctx context.Context, identityClaim string) (string, error)\n```\nGetIdentityFromContext returns the configured JWT claim value used as the request identity.\n\n```go\nfunc GetJWTIssuerConfigFromContext(ctx context.Context) (config.JWTIssuerConfig, bool)\n```\n\n```go\nfunc GetJWTTokenFromContext(ctx context.Context) *jwt.Token\n```\n\n```go\nfunc GetUsernameFromContext(ctx context.Context) string\n```\n\n```go\nfunc SetJWTIssuerConfigContext(ctx context.Context, cfg config.JWTIssuerConfig) context.Context\n```\n\n```go\nfunc SetJWTTokenContext(ctx context.Context, token *jwt.Token) context.Context\n```\n\n```go\nfunc SetUsernameContext(ctx context.Context, username string) context.Context\n```\n\n```go\nfunc ShouldSkipCallerIdentity(path string) bool\n```\nShouldSkipCallerIdentity reports whether path bypasses caller identity resolution. Exported so pkg/tenant can reuse the same skip list for tenant enforcement instead of maintaining a second copy of these path prefixes.\n\n## Types\n\n```go\ntype CallerIdentityMiddleware interface {\n\tResolveCallerIdentity(next http.Handler) http.Handler\n}\n```\nCallerIdentityMiddleware resolves and attaches the caller identity used for audit fields.\n\n```go\nfunc NewCallerIdentityMiddleware() CallerIdentityMiddleware\n```\n\n```go\ntype JWTHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nJWTHandler validates JWT tokens on incoming requests. Call Close() during shutdown to stop the background JWKS refresh goroutine.\n\n```go\nfunc NewJWTHandler(ctx context.Context, cfg JWTHandlerConfig) (*JWTHandler, error)\n```\n\n```go\nfunc (h *JWTHandler) Close() error\n```\n\n```go\nfunc (h *JWTHandler) Middleware(next http.Handler) http.Handler\n```\nMiddleware 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.\n\n```go\ntype JWTHandlerConfig struct {\n\tIssuers []config.JWTIssuerConfig\n}\n```\n\n```go\ntype Payload struct {\n\tUsername  string `json:\"username\"`\n\tFirstName string `json:\"first_name\"`\n\tLastName  string `json:\"last_name\"`\n\tEmail     string `json:\"email\"`\n\tIssuer    string `json:\"iss\"`\n\tClientID  string `json:\"clientId\"`\n}\n```\nPayload defines the structure of the JWT payload we expect\n\n```go\nfunc GetAuthPayloadFromContext(ctx context.Context) (*Payload, error)\n```\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/auth","name":"auth","synopsis":"","isRedistributable":true}
