Documentation
¶
Index ¶
- Constants
- Variables
- func AuthzMiddleware(ctr *cmk.APIController) func(http.Handler) http.Handler
- func BusinessUserDataMiddleware(signingKeyStorage keyvalue.ReadOnlyStringToBytesStorage, ...) func(http.Handler) http.Handler
- func ExtractPatternForTest(pattern, basePath string) string
- func InjectMultiTenancy() func(http.Handler) http.Handler
- func InjectRequestID() func(http.Handler) http.Handler
- func LoggingMiddleware() func(http.Handler) http.Handler
- func OAPIMiddleware(swagger *openapi3.T) func(next http.Handler) http.Handler
- func PanicRecoveryMiddleware() func(http.Handler) http.Handler
- func TracingMiddleware(cfg *config.Config) func(http.Handler) http.Handler
- type RoleGetter
Constants ¶
const (
// TenantPathParamName is the name of the path parameter used to extract the tenant ID.
TenantPathParamName = "tenant"
)
Variables ¶
var ( ErrNoBusinessUserDataHeader = errors.New("no client data header found") ErrMissingSignatureHeader = errors.New("missing client data signature header") ErrPublicKeyNotFound = errors.New("public key not found or invalid") ErrVerifySignatureFailed = errors.New("failed to verify client data signature") ErrDecodeBusinessUserData = errors.New("failed to decode business data from header") ErrTriedToBeSystem = errors.New("attempted to be system") )
Functions ¶
func AuthzMiddleware ¶
func BusinessUserDataMiddleware ¶ added in v0.9.0
func BusinessUserDataMiddleware( signingKeyStorage keyvalue.ReadOnlyStringToBytesStorage, authContextFields []string, roleGetter RoleGetter, ) func(http.Handler) http.Handler
BusinessUserDataMiddleware extracts client data from headers, verifies, and adds to context
func ExtractPatternForTest ¶ added in v0.9.0
ExtractPatternForTest is a test helper that exposes extractPattern for unit testing
func InjectMultiTenancy ¶
InjectMultiTenancy returns a middleware that extracts the tenant ID from the request path parameter and stores it in the request context.
func InjectRequestID ¶
InjectRequestID injects a RequestID into the context to be used by other middlewares
func LoggingMiddleware ¶
LoggingMiddleware logs the start and end of each request, along with the duration and status code.
func OAPIMiddleware ¶
OAPIMiddleware validates a Request against the OpenAPI Spec Also registers a decoder for merge-patch+json
func PanicRecoveryMiddleware ¶
PanicRecoveryMiddleware is a middleware that recovers from panics and logs them.
Types ¶
type RoleGetter ¶
type RoleGetter interface {
GetRoleFromIAM(ctx context.Context, iamIdentifiers []string) (constants.BusinessRole, error)
}
RoleGetter defines the interface for getting roles from group IAM identifiers for better unit testing