Help us shape the future of Go! Take the 2026 Go Developer Survey

middlewares

package
v1.321.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequireAuthOrAPIKeyMiddlewareID        = "requireAuthOrAPIKey"
	RequireInternalAdminAPIKeyMiddlewareID = "requireInternalAdminAPIKey"
	RequireInternalAdminOrAuthMiddlewareID = "requireInternalAdminOrAuth"
)
View Source
const ValidatedInputKey validatedInputKeyType = "validatedInput"

Variables

This section is empty.

Functions

func APIKeyPrincipal

func APIKeyPrincipal(e *core.RequestEvent) (*core.Record, *apierror.APIError)

APIKeyPrincipal resolves the Credimi-Api-Key of the request, accepting the same internal-admin and user-scoped keys as RequireInternalAdminOrAuth. It returns a nil principal when the request carries no key.

func DynamicValidateInputByType

func DynamicValidateInputByType(inputType reflect.Type) func(e *core.RequestEvent) error

func ErrorHandlingMiddleware

func ErrorHandlingMiddleware(e *core.RequestEvent) error

ErrorHandlingMiddleware renders every error of a Credimi route group as an apierror.Response.

Handlers return *apierror.APIError. PocketBase errors (apis.New*Error, e.BadRequestError and the other RequestEvent helpers) keep their status, so a stray one never turns into a 500; any other error is a 500.

func OptionalAuthOrAPIKey

func OptionalAuthOrAPIKey() *hook.Handler[*core.RequestEvent]

OptionalAuthOrAPIKey authenticates a Credimi-Api-Key when present, but does not block requests that provide no credentials.

func RequireAuthOrAPIKey

func RequireAuthOrAPIKey() *hook.Handler[*core.RequestEvent]

RequireAuthOrAPIKey accepts either a Bearer token or a user-scoped API key.

func RequireInternalAdminAPIKey

func RequireInternalAdminAPIKey() *hook.Handler[*core.RequestEvent]

RequireInternalAdminAPIKey requires an internal-admin API key.

func RequireInternalAdminOrAuth

func RequireInternalAdminOrAuth() *hook.Handler[*core.RequestEvent]

RequireInternalAdminOrAuth accepts either an internal-admin API key or a user auth context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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