Skip to main content

AuthorizationCode

Struct AuthorizationCode 

Source
pub struct AuthorizationCode {
    pub client_id: String,
    pub redirect_uri: String,
    pub user_id: String,
    pub scopes: Scopes,
    pub challenge: String,
    pub challenge_method: ChallengeMethod,
    pub issued_at: u64,
    pub expires_at: u64,
    pub family: Option<String>,
    /* private fields */
}
Expand description

One issued authorisation code.

The code itself is not here — only its digest. The plaintext exists once, in the redirect that carries it.

Fields§

§client_id: String§redirect_uri: String

The exact redirect URI this code was issued for. The token endpoint requires the same string again, which is what stops a code obtained through one registered URI being redeemed as though it came from another.

§user_id: String§scopes: Scopes§challenge: String§challenge_method: ChallengeMethod§issued_at: u64§expires_at: u64§family: Option<String>

Set when the code is spent: the token family the exchange produced, so a later replay knows what to revoke.

Implementations§

Source§

impl AuthorizationCode

Source

pub fn issued(code: &str, now: u64, ttl: u64) -> AuthorizationCode

Build a record for a code that is about to be handed out.

Source

pub fn for_client(self, client_id: impl Into<String>) -> AuthorizationCode

Source

pub fn for_user(self, user_id: impl Into<String>) -> AuthorizationCode

Source

pub fn redirecting_to(self, uri: impl Into<String>) -> AuthorizationCode

Source

pub fn granting(self, scopes: Scopes) -> AuthorizationCode

Source

pub fn challenged( self, challenge: impl Into<String>, method: ChallengeMethod, ) -> AuthorizationCode

Source

pub fn from_hash(hash: impl Into<String>) -> AuthorizationCode

The digest this record is stored under. Rebuild from a stored digest, for a CodeStore backed by a table.

The plaintext code is not needed and must not be available. Every other field is public and is set by the caller from the same row.

Source

pub fn hash(&self) -> &str

Source

pub fn is_consumed(&self) -> bool

Whether the code was spent, whatever the outcome of that exchange.

Source

pub fn is_expired(&self, now: u64) -> bool

Trait Implementations§

Source§

impl Clone for AuthorizationCode

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 AuthorizationCode

Debug prints no digest: it is the key a stolen log would need in order to recognise a code it also captured.

Source§

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

Formats the value using the given formatter. Read more

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, 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 = !

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.