Documentation
¶
Index ¶
- Variables
- func NewAudit(publisher event.Publisher) api.Middleware
- func NewAuth(registry api.AuthStrategyRegistry, checker security.PermissionChecker) api.Middleware
- func NewContextual(db orm.DB) api.Middleware
- func NewDataPermission(resolver security.DataPermissionResolver) api.Middleware
- func NewRateLimit() api.Middleware
- type Audit
- type Auth
- type Chain
- type Contextual
- type DataPermissionMiddleware
- type RateLimit
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOperationNotFound indicates the operation was not found in context. ErrOperationNotFound = errors.New("operation not found in request context") // ErrPrincipalNotFound indicates the principal was not found in context. ErrPrincipalNotFound = errors.New("principal not found in request context") // ErrRequestNotFound indicates the request was not found in context. ErrRequestNotFound = errors.New("request not found in request context") // ErrAuthStrategyNotFound indicates the auth strategy was not registered. ErrAuthStrategyNotFound = errors.New("authentication strategy not found") // ErrPermissionCheckerNotProvided indicates no permission checker was configured. ErrPermissionCheckerNotProvided = errors.New("permission checker not provided") // ErrDataPermissionResolverNotProvided indicates no data permission resolver was configured. ErrDataPermissionResolverNotProvided = errors.New("data permission resolver not provided") // ErrPermissionDenied indicates the principal does not have the required permission. ErrPermissionDenied = errors.New("permission denied") // ErrPermissionCheckFailed indicates an error occurred during permission check. ErrPermissionCheckFailed = errors.New("permission check failed") // ErrDataScopeResolutionFailed indicates an error occurred during data scope resolution. ErrDataScopeResolutionFailed = errors.New("data scope resolution failed") // ErrAuditEventBuildFailed indicates an error occurred while building audit event. ErrAuditEventBuildFailed = errors.New("failed to build audit event") // ErrResponseDecodeFailed indicates an error occurred while decoding response body. ErrResponseDecodeFailed = errors.New("failed to decode response body") )
var Module = fx.Module( "vef:api:middleware", fx.Provide( fx.Private, fx.Annotate( NewAudit, fx.ResultTags(`group:"vef:api:middlewares"`), ), fx.Annotate( NewAuth, fx.ResultTags(`group:"vef:api:middlewares"`), ), fx.Annotate( NewContextual, fx.ResultTags(`group:"vef:api:middlewares"`), ), fx.Annotate( NewDataPermission, fx.ResultTags(`group:"vef:api:middlewares"`), ), fx.Annotate( NewRateLimit, fx.ResultTags(`group:"vef:api:middlewares"`), ), ), fx.Provide( fx.Annotate( NewChain, fx.ParamTags(`group:"vef:api:middlewares"`), ), ), )
Functions ¶
func NewAudit ¶
func NewAudit(publisher event.Publisher) api.Middleware
NewAudit creates a new audit middleware.
func NewAuth ¶
func NewAuth(registry api.AuthStrategyRegistry, checker security.PermissionChecker) api.Middleware
NewAuth creates a new authentication middleware.
func NewContextual ¶
func NewContextual(db orm.DB) api.Middleware
NewContextual creates a new context middleware.
func NewDataPermission ¶
func NewDataPermission(resolver security.DataPermissionResolver) api.Middleware
NewDataPermission creates a new data permission middleware.
func NewRateLimit ¶
func NewRateLimit() api.Middleware
NewRateLimit creates a new rate limit middleware with shared state.
Types ¶
type Audit ¶
type Audit struct {
// contains filtered or unexported fields
}
Audit handles audit logging.
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain manages the middleware chain for API requests.
func NewChain ¶
func NewChain(middlewares ...api.Middleware) *Chain
NewChain creates a new middleware chain with the given middlewares. Middlewares are sorted by their Order() value (ascending).
type Contextual ¶
type Contextual struct {
// contains filtered or unexported fields
}
Contextual injects DB and Logger into the request context. It sets up a contextual database with the operator ID and a scoped logger with request identification information.
func (*Contextual) Order ¶
func (*Contextual) Order() int
Order returns the middleware order. Runs after authentication (-100) but before authorization (-90).
type DataPermissionMiddleware ¶
type DataPermissionMiddleware struct {
// contains filtered or unexported fields
}
DataPermissionMiddleware handles data permission resolution. It resolves data scope for the current principal and permission token, then injects a RequestScopedDataPermApplier into the context.
func (*DataPermissionMiddleware) Name ¶
func (*DataPermissionMiddleware) Name() string
Name returns the middleware name.
func (*DataPermissionMiddleware) Order ¶
func (*DataPermissionMiddleware) Order() int
Order returns the middleware order. Runs after authentication (-100) but before rate limiting (-80).