middleware

package
v0.0.0-...-9cf9cea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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 BasicAuthMiddleware(adminAccount, adminApiKey string) func(http.Handler) http.Handler

func CSPMiddleware

func CSPMiddleware() func(http.Handler) http.Handler

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 CorsMiddleware(corsAllowedOrigins []string) func(http.Handler) http.Handler

func EnsureTenantMiddleware

func EnsureTenantMiddleware(next http.Handler) http.Handler

EnsureTenantMiddleware is a middleware that ensures the tenant is in the request context.

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

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

func RecoverHandler(next http.Handler) http.Handler

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL