#[non_exhaustive]pub enum AuthRequest {
Show 21 variants
Config,
Me,
Login(LoginRequest),
CloudflareSignIn,
Logout,
RegisterInfo {
token: String,
},
Register {
token: String,
request: RegisterRequest,
},
ChangePassword(PasswordChange),
UpdateAccount(UserChange),
Users,
CreateUser(NewUser),
UpdateUser {
id: UserId,
change: UserChange,
},
DeleteUser {
id: UserId,
},
IssueLink {
id: UserId,
},
RevokeLink {
id: UserId,
},
SignOutUser {
id: UserId,
},
RevokeAccess {
id: UserId,
},
Impersonate {
id: UserId,
},
StopImpersonating,
Cloudflare,
SetCloudflare(CloudflareConfig),
}alloc only.Expand description
One operation of watchword’s service, as the server’s Auth::dispatch
runs it and a frontend’s transport carries it.
This is plumbing, not a wire format: it has no serde or musli
derives. The HTTP routes keep their paths and JSON bodies, and the
musli-web endpoints their own request types; each transport decodes its
request into an AuthRequest, has it dispatched, and encodes the
AuthResponse as that route or endpoint answers. Since every
transport runs the same dispatch, an operation behaves the same over each.
The operations that set, replace or clear the session cookie say so
with cookie. Only an HTTP response can carry the
cookie, so those go over HTTP.
New operations are added as new variants, so a match on it needs a
wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config
The sign-in methods on offer, AuthConfig. Anyone. GET /api/auth/config.
Me
The signed-in user, with UserInfo::impersonated_by when an admin
is acting as them. Signed in. GET /api/auth/me, the musli-web
endpoint Me.
Login(LoginRequest)
Signs in with a password. Anyone; throttled by the client’s address.
Sets the cookie. POST /api/auth/login.
CloudflareSignIn
Signs in the user the request’s Cloudflare Access credentials vouch
for. Anyone. Sets the cookie. POST /api/auth/cloudflare.
Logout
Ends the session. Anyone. Clears the cookie. POST /api/auth/logout.
RegisterInfo
What a registration or reset link is for. Anyone. GET /api/auth/register/{token}.
Register
Registers, or resets the password, with a link. Anyone. Sets the
cookie. POST /api/auth/register/{token}.
ChangePassword(PasswordChange)
Sets or changes the signed-in user’s password. Signed in. POST /api/auth/account/password, the musli-web endpoint ChangePassword.
UpdateAccount(UserChange)
Changes the signed-in user’s own login or email, not their role.
Signed in. PATCH /api/auth/account, the musli-web endpoint
UpdateAccount.
Users
Every user. Admins. GET /api/auth/users, the musli-web endpoint
Users.
CreateUser(NewUser)
Creates a user and their registration link. Admins. POST /api/auth/users, the musli-web endpoint CreateUser.
UpdateUser
Changes another user. Admins. PATCH /api/auth/users/{id}, the
musli-web endpoint UpdateUser.
DeleteUser
Deletes another user. Admins. DELETE /api/auth/users/{id}, the
musli-web endpoint DeleteUser.
IssueLink
Issues a registration or reset link for a user. Admins. POST /api/auth/users/{id}/link, the musli-web endpoint IssueLink.
RevokeLink
Uses up a user’s links. Admins. DELETE /api/auth/users/{id}/link,
the musli-web endpoint RevokeLink.
SignOutUser
Ends every session of a user. Admins. POST /api/auth/users/{id}/sign-out, the musli-web endpoint SignOutUser.
RevokeAccess
Revokes another user’s access. Admins. POST /api/auth/users/{id}/revoke, the musli-web endpoint RevokeAccess.
Impersonate
Signs in as another user, in a session marked with the admin. Admins,
if impersonation is enabled. Replaces the cookie. POST /api/auth/users/{id}/impersonate.
StopImpersonating
Ends an impersonated session, signing the admin back in. Signed in,
impersonated. Replaces the cookie. POST /api/auth/impersonate/stop.
Cloudflare
The Cloudflare Access settings. Admins. GET /api/auth/cloudflare,
the musli-web endpoint Cloudflare.
SetCloudflare(CloudflareConfig)
Stores and applies the Cloudflare Access settings. Admins. PUT /api/auth/cloudflare, the musli-web endpoint SetCloudflare.
Implementations§
Source§impl AuthRequest
impl AuthRequest
What the operation does to the session cookie, or None when it
leaves it alone.
Only an HTTP response can set or clear the HttpOnly cookie, so an
operation with a CookieChange must go over HTTP; the server’s
socket adapter has no endpoint for one. One that
replaces the cookie also leaves a socket
opened with the earlier session speaking for that session.