Skip to main content

Client

Struct Client 

Source
pub struct Client {
    pub client_id: ClientId,
    pub auth: ClientAuth,
    pub grant_types: Vec<GrantType>,
    pub redirect_uris: Vec<String>,
    pub allowed_scopes: ScopeSet,
    pub default_scopes: ScopeSet,
    pub name: Option<String>,
    pub registration: Option<Box<DynamicRegistration>>,
}
Expand description

A registered client: identity, authentication, and what it is allowed to do.

Fields§

§client_id: ClientId

The unique client identifier.

§auth: ClientAuth

How the client authenticates.

§grant_types: Vec<GrantType>

The grant types this registration may use; anything else is unauthorized_client.

§redirect_uris: Vec<String>

Registered redirect URIs (authorization-code grant; exact-match per OAuth 2.1).

§allowed_scopes: ScopeSet

The scopes this client may ever be granted; a request outside this set is invalid_scope.

§default_scopes: ScopeSet

The scopes granted when a request names none (RFC 6749 section 3.3 server default).

§name: Option<String>

Human-readable name for consent and admin surfaces.

§registration: Option<Box<DynamicRegistration>>

Present exactly when this registration was created by RFC 7591 dynamic client registration, and absent for one the host provisioned itself.

BOXED, and this is not a style choice, though the reason is no longer the one it was written for. The original argument was that a Client is deep cloned out of the store on every token-plane request, so every byte here is paid per request; crate::store::Storage::get_client hands back an Arc<Client> now, so a read is a pointer clone and the struct’s SIZE is not on that path at all.

Re-examined on that basis, the box is MORE clearly right than when it was chosen, because the optimisation removed its only cost. What it buys is now a memory argument rather than a per-request one. MEASURED: Option<Box<DynamicRegistration>> is 8 bytes against 104 for the record inline, which is the difference between a Client of 200 bytes and one of 296, paid by every registration in every store whether or not RFC 7591 is enabled. What it USED to cost was an extra allocation on every clone of a client that does have one; with Arc there are no such clones, so that allocation is now paid exactly once, when the registration is created.

It lives on the client rather than in a table of its own because it IS the client: RFC 7592 section 2 manages a registration through the same identifier the token endpoint authenticates, and splitting the two across two stores would make deletion a two-phase problem the host has to get right.

Implementations§

Source§

impl Client

Source

pub fn allows_grant(&self, grant_type: GrantType) -> bool

Whether the registration permits grant_type.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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 Client

Source§

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

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

impl<'de> Deserialize<'de> for Client

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Client

Source§

impl PartialEq for Client

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Client

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Client

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.