1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Save the post auth action during upstream OAuth login

This commit is contained in:
Quentin Gliech
2022-12-05 18:27:56 +01:00
parent 4d93f4d4f0
commit 23fd833d45
18 changed files with 142 additions and 100 deletions

View File

@ -532,17 +532,27 @@ impl Route for CompatLoginSsoComplete {
/// `GET /upstream/authorize/:id`
pub struct UpstreamOAuth2Authorize {
id: Ulid,
post_auth_action: Option<PostAuthAction>,
}
impl UpstreamOAuth2Authorize {
#[must_use]
pub const fn new(id: Ulid) -> Self {
Self { id }
Self {
id,
post_auth_action: None,
}
}
#[must_use]
pub fn and_then(mut self, action: PostAuthAction) -> Self {
self.post_auth_action = Some(action);
self
}
}
impl Route for UpstreamOAuth2Authorize {
type Query = ();
type Query = PostAuthAction;
fn route() -> &'static str {
"/upstream/authorize/:provider_id"
}
@ -550,6 +560,10 @@ impl Route for UpstreamOAuth2Authorize {
fn path(&self) -> std::borrow::Cow<'static, str> {
format!("/upstream/authorize/{}", self.id).into()
}
fn query(&self) -> Option<&Self::Query> {
self.post_auth_action.as_ref()
}
}
/// `GET /upstream/callback/:id`