Documentation
¶
Overview ¶
Package authctx provides type-safe context propagation for authentication claims.
It uses Go generics so each project can store and retrieve its own claims type without gokit knowing about the specific fields.
Usage:
// Store claims (typically in middleware) ctx = authctx.Set(ctx, myClaims) // Retrieve claims (in handlers) claims, ok := authctx.Get[*MyClaims](ctx) claims := authctx.MustGet[*MyClaims](ctx) // panics if missing
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoClaims = errors.New("authctx: no claims in context")
ErrNoClaims is returned when claims are not found in the context.
Functions ¶
func Get ¶
Get retrieves typed authentication claims from the context. Returns the claims and true if found and of the correct type, or zero value and false otherwise.
func GetOrError ¶
GetOrError retrieves typed claims from the context. Returns ErrNoClaims if claims are missing or of the wrong type.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.