Documentation ¶
Index ¶
- Constants
- func AnyRoleMiddleware(authManager auth.AuthManager, requiredRoles ...data.UserRole) func(http.Handler) http.Handler
- func AuthenticateMiddleware(authManager auth.AuthManager, tenantManager tenant.ManagerInterface) func(http.Handler) http.Handler
- func BasicAuthMiddleware(adminAccount, adminApiKey string) func(http.Handler) http.Handler
- func CSPMiddleware() func(http.Handler) http.Handler
- func CorsMiddleware(corsAllowedOrigins []string) func(http.Handler) http.Handler
- func EnsureTenantMiddleware(next http.Handler) http.Handler
- func LoggingMiddleware(next http.Handler) http.Handler
- func MetricsRequestHandler(monitorService monitor.MonitorServiceInterface) func(next http.Handler) http.Handler
- func RecoverHandler(next http.Handler) http.Handler
- func ResolveTenantFromRequestMiddleware(tenantManager tenant.ManagerInterface, singleTenantMode bool) func(http.Handler) http.Handler
- type ContextKey
Constants ¶
const ( TokenContextKey ContextKey = "auth_token" TenantHeaderKey string = "SDP-Tenant-Name" )
Variables ¶
This section is empty.
Functions ¶
func AnyRoleMiddleware ¶
func AnyRoleMiddleware(authManager auth.AuthManager, requiredRoles ...data.UserRole) func(http.Handler) http.Handler
AnyRoleMiddleware validates if the user has at least one of the required roles to request the current endpoint.
func AuthenticateMiddleware ¶
func AuthenticateMiddleware(authManager auth.AuthManager, tenantManager tenant.ManagerInterface) func(http.Handler) http.Handler
AuthenticateMiddleware is a middleware that validates the Authorization header for authenticated endpoints.
func BasicAuthMiddleware ¶
func CSPMiddleware ¶
CSPMiddleware is the middleware that sets the content security policy, restricting content to only be accessed from specified sources in the header.
func CorsMiddleware ¶
func EnsureTenantMiddleware ¶
EnsureTenantMiddleware is a middleware that ensures the tenant is in the request context.
func LoggingMiddleware ¶
LoggingMiddleware is a middleware that logs requests to the logger.
func MetricsRequestHandler ¶
func MetricsRequestHandler(monitorService monitor.MonitorServiceInterface) func(next http.Handler) http.Handler
MetricsRequestHandler is a middleware that monitors http requests, and export the data to the metrics server
func RecoverHandler ¶
RecoverHandler is a middleware that recovers from panics and logs the error.
func ResolveTenantFromRequestMiddleware ¶
func ResolveTenantFromRequestMiddleware(tenantManager tenant.ManagerInterface, singleTenantMode bool) func(http.Handler) http.Handler
ResolveTenantFromRequestMiddleware is a middleware that injects the tenant into the request context, if it can be found in the request HEADER, or the hostname prefix.
Types ¶
type ContextKey ¶
type ContextKey string