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: StringThe 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
impl AuthorizationCode
Sourcepub fn issued(code: &str, now: u64, ttl: u64) -> AuthorizationCode
pub fn issued(code: &str, now: u64, ttl: u64) -> AuthorizationCode
Build a record for a code that is about to be handed out.
pub fn for_client(self, client_id: impl Into<String>) -> AuthorizationCode
pub fn for_user(self, user_id: impl Into<String>) -> AuthorizationCode
pub fn redirecting_to(self, uri: impl Into<String>) -> AuthorizationCode
pub fn granting(self, scopes: Scopes) -> AuthorizationCode
pub fn challenged( self, challenge: impl Into<String>, method: ChallengeMethod, ) -> AuthorizationCode
Sourcepub fn from_hash(hash: impl Into<String>) -> AuthorizationCode
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.
pub fn hash(&self) -> &str
Sourcepub fn is_consumed(&self) -> bool
pub fn is_consumed(&self) -> bool
Whether the code was spent, whatever the outcome of that exchange.