Documentation
¶
Overview ¶
Package middleware exposes HTTP middleware adapters for JWT-only, hybrid, and strict authorization enforcement modes built on top of goAuth.Engine validation.
Guards ¶
- Guard — auto-selects enforcement mode from Engine config.
- RequireJWTOnly — stateless JWT verification, no Redis call.
- RequireStrict — JWT + session store verification.
Each guard reads the Authorization header, calls Engine.Validate, and injects validated claims into the request context.
Architecture boundaries ¶
This package translates HTTP semantics into Engine calls. It does NOT implement authentication logic itself — all decisions are delegated to Engine.Validate.
What this package must NOT do ¶
- Parse or create JWTs directly (delegates to Engine).
- Access Redis (Engine handles I/O).
- Make authorization decisions beyond pass/reject from Engine.Validate.
Index ¶
- func AuthResultFromContext(ctx context.Context) (*goAuth.AuthResult, bool)
- func Guard(engine *goAuth.Engine, routeMode goAuth.RouteMode) func(http.Handler) http.Handler
- func RequireHybrid(engine *goAuth.Engine) func(http.Handler) http.Handler
- func RequireJWTOnly(engine *goAuth.Engine) func(http.Handler) http.Handler
- func RequireStrict(engine *goAuth.Engine) func(http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthResultFromContext ¶
func AuthResultFromContext(ctx context.Context) (*goAuth.AuthResult, bool)
AuthResultFromContext extracts the goAuth.AuthResult stored by Guard middleware from the request context.
Docs: docs/middleware.md
func Guard ¶
Guard returns HTTP middleware that validates access tokens on every request using the provided goAuth.Engine. On success, the goAuth.AuthResult is stored in context for downstream handlers.
Docs: docs/middleware.md, docs/flows.md#validate
func RequireHybrid ¶ added in v0.4.0
RequireHybrid returns middleware that overrides the validation mode to goAuth.ModeHybrid for the wrapped handler. Hybrid routes validate the JWT statelessly (signature, claims, clock skew — zero Redis); use RequireStrict on routes that need session-backed revocation checks.
Docs: docs/middleware.md, docs/jwt.md
func RequireJWTOnly ¶
RequireJWTOnly returns middleware that overrides the validation mode to goAuth.ModeJWTOnly for the wrapped handler, skipping Redis entirely.
Docs: docs/middleware.md, docs/jwt.md
func RequireStrict ¶
RequireStrict returns middleware that overrides the validation mode to goAuth.ModeStrict for the wrapped handler, forcing a Redis session lookup on every request.
Docs: docs/middleware.md, docs/jwt.md
Types ¶
This section is empty.