You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
data-model: simplify the authorization grants and sessions
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use axum::response::{Html, IntoResponse, Redirect, Response};
|
||||
use mas_data_model::{AuthorizationGrant, StorageBackend};
|
||||
use mas_data_model::AuthorizationGrant;
|
||||
use mas_templates::{FormPostContext, Templates};
|
||||
use oauth2_types::requests::ResponseMode;
|
||||
use serde::Serialize;
|
||||
@@ -61,10 +61,10 @@ pub enum CallbackDestinationError {
|
||||
ParamsSerialization(#[from] serde_urlencoded::ser::Error),
|
||||
}
|
||||
|
||||
impl<S: StorageBackend> TryFrom<&AuthorizationGrant<S>> for CallbackDestination {
|
||||
impl TryFrom<&AuthorizationGrant> for CallbackDestination {
|
||||
type Error = IntoCallbackDestinationError;
|
||||
|
||||
fn try_from(value: &AuthorizationGrant<S>) -> Result<Self, Self::Error> {
|
||||
fn try_from(value: &AuthorizationGrant) -> Result<Self, Self::Error> {
|
||||
Self::try_new(
|
||||
&value.response_mode,
|
||||
value.redirect_uri.clone(),
|
||||
|
||||
@@ -32,7 +32,6 @@ use mas_storage::{
|
||||
consent::fetch_client_consent,
|
||||
},
|
||||
user::ActiveSessionLookupError,
|
||||
PostgresqlBackend,
|
||||
};
|
||||
use mas_templates::Templates;
|
||||
use oauth2_types::requests::{AccessTokenResponse, AuthorizationResponse};
|
||||
@@ -185,7 +184,7 @@ impl From<IntoCallbackDestinationError> for GrantCompletionError {
|
||||
}
|
||||
|
||||
pub(crate) async fn complete(
|
||||
grant: AuthorizationGrant<PostgresqlBackend>,
|
||||
grant: AuthorizationGrant,
|
||||
browser_session: BrowserSession,
|
||||
policy_factory: &PolicyFactory,
|
||||
mut txn: Transaction<'_, Postgres>,
|
||||
|
||||
@@ -315,7 +315,7 @@ pub(crate) async fn get(
|
||||
requires_consent,
|
||||
)
|
||||
.await?;
|
||||
let continue_grant = PostAuthAction::continue_grant(grant.data);
|
||||
let continue_grant = PostAuthAction::continue_grant(grant.id);
|
||||
|
||||
let res = match maybe_session {
|
||||
// Cases where there is no active session, redirect to the relevant page
|
||||
@@ -391,7 +391,7 @@ pub(crate) async fn get(
|
||||
}
|
||||
}
|
||||
Some(user_session) => {
|
||||
let grant_id = grant.data;
|
||||
let grant_id = grant.id;
|
||||
// Else, we show the relevant reauth/consent page if necessary
|
||||
match self::complete::complete(grant, user_session, &policy_factory, txn).await
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ impl OptionalPostAuthAction {
|
||||
let ctx = match action {
|
||||
PostAuthAction::ContinueAuthorizationGrant { data } => {
|
||||
let grant = get_grant_by_id(conn, data).await?;
|
||||
let grant = Box::new(grant.into());
|
||||
let grant = Box::new(grant);
|
||||
PostAuthContextInner::ContinueAuthorizationGrant { grant }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user