You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
@ -60,6 +60,10 @@ where
|
|||||||
{
|
{
|
||||||
// All those routes are API-like, with a common CORS layer
|
// All those routes are API-like, with a common CORS layer
|
||||||
let api_router = Router::new()
|
let api_router = Router::new()
|
||||||
|
.route(
|
||||||
|
mas_router::ChangePasswordDiscovery::route(),
|
||||||
|
get(|| async { mas_router::AccountPassword.go() }),
|
||||||
|
)
|
||||||
.route(
|
.route(
|
||||||
mas_router::OidcConfiguration::route(),
|
mas_router::OidcConfiguration::route(),
|
||||||
get(self::oauth2::discovery::get),
|
get(self::oauth2::discovery::get),
|
||||||
|
@ -54,7 +54,7 @@ pub(crate) async fn get(
|
|||||||
if let Some(session) = maybe_session {
|
if let Some(session) = maybe_session {
|
||||||
render(templates, session, cookie_jar).await
|
render(templates, session, cookie_jar).await
|
||||||
} else {
|
} else {
|
||||||
let login = mas_router::Login::default();
|
let login = mas_router::Login::and_then(mas_router::PostAuthAction::ChangePassword);
|
||||||
Ok((cookie_jar, login.go()).into_response())
|
Ok((cookie_jar, login.go()).into_response())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ pub(crate) async fn post(
|
|||||||
let mut session = if let Some(session) = maybe_session {
|
let mut session = if let Some(session) = maybe_session {
|
||||||
session
|
session
|
||||||
} else {
|
} else {
|
||||||
let login = mas_router::Login::default();
|
let login = mas_router::Login::and_then(mas_router::PostAuthAction::ChangePassword);
|
||||||
return Ok((cookie_jar, login.go()).into_response());
|
return Ok((cookie_jar, login.go()).into_response());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,9 +38,10 @@ impl OptionalPostAuthAction {
|
|||||||
match &self.post_auth_action {
|
match &self.post_auth_action {
|
||||||
Some(PostAuthAction::ContinueAuthorizationGrant { data }) => {
|
Some(PostAuthAction::ContinueAuthorizationGrant { data }) => {
|
||||||
let grant = get_grant_by_id(conn, *data).await?;
|
let grant = get_grant_by_id(conn, *data).await?;
|
||||||
let grant = grant.into();
|
let grant = Box::new(grant.into());
|
||||||
Ok(Some(PostAuthContext::ContinueAuthorizationGrant { grant }))
|
Ok(Some(PostAuthContext::ContinueAuthorizationGrant { grant }))
|
||||||
}
|
}
|
||||||
|
Some(PostAuthAction::ChangePassword) => Ok(Some(PostAuthContext::ChangePassword)),
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ pub enum PostAuthAction {
|
|||||||
#[serde(deserialize_with = "serde_with::rust::display_fromstr::deserialize")]
|
#[serde(deserialize_with = "serde_with::rust::display_fromstr::deserialize")]
|
||||||
data: i64,
|
data: i64,
|
||||||
},
|
},
|
||||||
|
ChangePassword,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PostAuthAction {
|
impl PostAuthAction {
|
||||||
@ -35,6 +36,7 @@ impl PostAuthAction {
|
|||||||
pub fn go_next(&self) -> axum::response::Redirect {
|
pub fn go_next(&self) -> axum::response::Redirect {
|
||||||
match self {
|
match self {
|
||||||
Self::ContinueAuthorizationGrant { data } => ContinueAuthorizationGrant(*data).go(),
|
Self::ContinueAuthorizationGrant { data } => ContinueAuthorizationGrant(*data).go(),
|
||||||
|
Self::ChangePassword => AccountPassword.go(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,6 +57,13 @@ impl SimpleRoute for Webfinger {
|
|||||||
const PATH: &'static str = "/.well-known/webfinger";
|
const PATH: &'static str = "/.well-known/webfinger";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `GET /.well-known/change-password`
|
||||||
|
pub struct ChangePasswordDiscovery;
|
||||||
|
|
||||||
|
impl SimpleRoute for ChangePasswordDiscovery {
|
||||||
|
const PATH: &'static str = "/.well-known/change-password";
|
||||||
|
}
|
||||||
|
|
||||||
/// `GET /oauth2/keys.json`
|
/// `GET /oauth2/keys.json`
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct OAuth2Keys;
|
pub struct OAuth2Keys;
|
||||||
|
@ -245,8 +245,11 @@ pub enum PostAuthContext {
|
|||||||
/// Continue an authorization grant
|
/// Continue an authorization grant
|
||||||
ContinueAuthorizationGrant {
|
ContinueAuthorizationGrant {
|
||||||
/// The authorization grant that will be continued after authentication
|
/// The authorization grant that will be continued after authentication
|
||||||
grant: AuthorizationGrant<()>,
|
grant: Box<AuthorizationGrant<()>>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Change the account password
|
||||||
|
ChangePassword,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Context used by the `login.html` template
|
/// Context used by the `login.html` template
|
||||||
|
Reference in New Issue
Block a user