Documentation
¶
Index ¶
- func ApiAuthOrErrorMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler
- func ImpersonationAwareMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler
- func WebAppendUserIdIfExistsMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler
- func WebAuthOrRedirectMiddleware(next http.Handler, a types.AuthSharedInterface) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApiAuthOrErrorMiddleware ¶
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 WebAppendUserIdIfExistsMiddleware ¶
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 ¶
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.