offstage_suweal/auth
Types
A type representing the authentication information of a user.
pub type UserAuth(a) {
UserAuth(id: identifier.Identifier(a))
}
Constructors
-
UserAuth(id: identifier.Identifier(a))
Values
pub fn get_user_token(
request: request.Request(offstage_core.Connection),
type_: String,
key: key.Key,
unauthorized: offstage.UnauthorizedResponse,
) -> Result(
identifier.Identifier(a),
response.Response(wisp.Body),
)
Get the identifier of the user from the authorization header and return an error if no token is
provided or if the token is invalid. The key is used to verify the JWT.
pub fn user_auth(
spec: offstage_core.RouteSpecBuilder,
name: String,
type_: String,
key: key.Key,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(UserAuth(a), next),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
Add user authentication to the route with the name for the security scheme, the type of the identifier and the JWT key to use.