1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Rewrite the authorization grant logic

This commit is contained in:
Quentin Gliech
2022-05-06 17:12:16 +02:00
parent fbd774a9fd
commit 436c0dcb19
22 changed files with 1141 additions and 915 deletions

View File

@@ -119,6 +119,14 @@ impl<T: StorageBackend> AuthorizationGrantStage<T> {
_ => Err(InvalidTransitionError),
}
}
/// Returns `true` if the authorization grant stage is [`Pending`].
///
/// [`Pending`]: AuthorizationGrantStage::Pending
#[must_use]
pub fn is_pending(&self) -> bool {
matches!(self, Self::Pending)
}
}
impl<S: StorageBackendMarker> From<AuthorizationGrantStage<S>> for AuthorizationGrantStage<()> {
@@ -166,6 +174,7 @@ pub struct AuthorizationGrant<T: StorageBackend> {
pub response_type_token: bool,
pub response_type_id_token: bool,
pub created_at: DateTime<Utc>,
pub requires_consent: bool,
}
impl<S: StorageBackendMarker> From<AuthorizationGrant<S>> for AuthorizationGrant<()> {
@@ -185,6 +194,7 @@ impl<S: StorageBackendMarker> From<AuthorizationGrant<S>> for AuthorizationGrant
response_type_token: g.response_type_token,
response_type_id_token: g.response_type_id_token,
created_at: g.created_at,
requires_consent: g.requires_consent,
}
}
}