Documentation
¶
Overview ¶
Package tenant provides stable tenant scoping middleware.
Use the middleware to place a tenant identifier in request context before authorization, idempotency, repositories, or audit logging need tenant-aware behavior. Invalid or missing tenant data should fail at the application edge according to the service's routing policy. Set Options.RequireAllSources when request-carried tenant identifiers must match an authenticated tenant scope or route parameter before the handler runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error)
ErrorHandler handles authorization errors from the tenant middleware.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware enforces tenant scoping and stores the tenant in context.
type Options ¶
type Options struct {
Optional bool
HeaderName string
URLParam string
URLParamExtractor ports.URLParamExtractor
TenantFromContext TenantFromContext
// RequireAllSources requires every configured tenant source to be present
// and to agree. Use it when a route must prove the request tenant matches
// the authenticated tenant scope.
RequireAllSources bool
ErrorHandler ErrorHandler
}
Options configures tenant scoping.