public final class GuardAuthenticationMiddleware<A> : Middleware where A : Authenticatable

This middleware ensures that an Authenticatable type A has been authenticated by a previous Middleware or throws an Error. The middlewares that actually perform authentication will not throw errors if they fail to authenticate the user (except in some exceptional cases like malformed data). This allows the middlewares to be composed together to create chains of authentication for multiple user types.

Use this middleware to protect routes that might not otherwise attempt to access the authenticated user (which always requires prior authentication).

Use Authenticatable.guardAuthMiddleware(...) to create an instance.

Use this middleware in conjunction with other middleware such as BearerAuthenticationMiddleware and BasicAuthenticationMiddleware to do the actual authentication.