middlewares

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiAuthOrErrorMiddleware

func ApiAuthOrErrorMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler

ApiAuthOrErrorMiddleware checks that an authentication token exists, and then finds the userID based on it. On success appends the user ID to the context. On failure it will return an unauthenticated JSON response.

func ImpersonationAwareMiddleware added in v0.33.0

func ImpersonationAwareMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler

func WebAppendUserIdIfExistsMiddleware

func WebAppendUserIdIfExistsMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler

WebAppendUserIdIfExistsMiddleware appends the user ID to the context if an authentication token exists in the requests. This middleware does not have a side effect like for instance redirecting to the login endpoint. This is why it is important to be added to places which can be used by both guests and users (i.e. website pages), where authenticated users may have some extra privileges

If you need to redirect the user if authentication token not found, or the user does not exist, take a look at the WebAuthOrRedirectMiddleware middleware, which does exactly that

func WebAuthOrRedirectMiddleware

func WebAuthOrRedirectMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler

WebAuthOrRedirectMiddleware checks that an authentication token exists, and then finds the userID based on it. On success appends the user ID to the context. On failure it will redirect the user to the login endpoint to reauthenticate.

If you need to only find if the authentication token is successful without redirection please use the WebAppendUserIdIfExistsMiddleware which does exactly that without side effects

Types

This section is empty.

Jump to

Keyboard shortcuts

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