Skip to main content

AuthRequest

Enum AuthRequest 

Source
#[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),
}
Available on crate feature 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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}.

Fields

§token: String

The link’s token.

§

Register

Registers, or resets the password, with a link. Anyone. Sets the cookie. POST /api/auth/register/{token}.

Fields

§token: String

The link’s token.

§request: RegisterRequest

The credentials to register with.

§

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.

Fields

§id: UserId

The user to change.

§change: UserChange

The change.

§

DeleteUser

Deletes another user. Admins. DELETE /api/auth/users/{id}, the musli-web endpoint DeleteUser.

Fields

§id: UserId

The user.

Issues a registration or reset link for a user. Admins. POST /api/auth/users/{id}/link, the musli-web endpoint IssueLink.

Fields

§id: UserId

The user.

Uses up a user’s links. Admins. DELETE /api/auth/users/{id}/link, the musli-web endpoint RevokeLink.

Fields

§id: UserId

The user.

§

SignOutUser

Ends every session of a user. Admins. POST /api/auth/users/{id}/sign-out, the musli-web endpoint SignOutUser.

Fields

§id: UserId

The user.

§

RevokeAccess

Revokes another user’s access. Admins. POST /api/auth/users/{id}/revoke, the musli-web endpoint RevokeAccess.

Fields

§id: UserId

The user.

§

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.

Fields

§id: UserId

The user to act as.

§

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

Source

pub fn cookie(&self) -> Option<CookieChange>

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.

Trait Implementations§

Source§

impl Clone for AuthRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuthRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for AuthRequest

Source§

impl PartialEq for AuthRequest

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AuthRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.