You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-21 23:00:50 +03:00
Upgrade axum to 0.5
This commit is contained in:
@@ -149,12 +149,8 @@ where
|
||||
.context("could not serialize redirect URI query params")?;
|
||||
|
||||
redirect_uri.set_query(Some(&new_qs));
|
||||
let redirect_uri = redirect_uri
|
||||
.as_str()
|
||||
.parse()
|
||||
.context("could not convert redirect URI")?;
|
||||
|
||||
Ok(Redirect::to(redirect_uri).into_response())
|
||||
Ok(Redirect::to(redirect_uri.as_str()).into_response())
|
||||
}
|
||||
ResponseMode::Fragment => {
|
||||
let existing: Option<HashMap<&str, &str>> = redirect_uri
|
||||
@@ -173,12 +169,8 @@ where
|
||||
.context("could not serialize redirect URI fragment params")?;
|
||||
|
||||
redirect_uri.set_fragment(Some(&new_qs));
|
||||
let redirect_uri = redirect_uri
|
||||
.as_str()
|
||||
.parse()
|
||||
.context("could not convert redirect URI")?;
|
||||
|
||||
Ok(Redirect::to(redirect_uri).into_response())
|
||||
Ok(Redirect::to(redirect_uri.as_str()).into_response())
|
||||
}
|
||||
ResponseMode::FormPost => {
|
||||
let merged = ParamsWithState { state, params };
|
||||
@@ -389,7 +381,7 @@ pub(crate) async fn get(
|
||||
let next: ReauthRequest = next.into();
|
||||
let next = next.build_uri()?;
|
||||
|
||||
Ok(Redirect::to(next).into_response())
|
||||
Ok(Redirect::to(&next.to_string()).into_response())
|
||||
}
|
||||
(Some(user_session), _) => {
|
||||
// Other cases where we already have a session
|
||||
@@ -403,7 +395,7 @@ pub(crate) async fn get(
|
||||
let next: RegisterRequest = next.into();
|
||||
let next = next.build_uri()?;
|
||||
|
||||
Ok(Redirect::to(next).into_response())
|
||||
Ok(Redirect::to(&next.to_string()).into_response())
|
||||
}
|
||||
(None, _) => {
|
||||
// Other cases where we don't have a session, ask for a login
|
||||
@@ -413,7 +405,7 @@ pub(crate) async fn get(
|
||||
let next: LoginRequest = next.into();
|
||||
let next = next.build_uri()?;
|
||||
|
||||
Ok(Redirect::to(next).into_response())
|
||||
Ok(Redirect::to(&next.to_string()).into_response())
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -424,7 +416,7 @@ pub(crate) async fn get(
|
||||
Err(_e) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
};
|
||||
|
||||
Ok((cookie_jar.headers(), response).into_response())
|
||||
Ok((cookie_jar, response).into_response())
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
@@ -486,7 +478,7 @@ pub(crate) async fn step_get(
|
||||
let next: PostAuthAction = next.into();
|
||||
let login: LoginRequest = next.into();
|
||||
let login = login.build_uri()?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
step(next, session, txn, &templates).await
|
||||
@@ -565,7 +557,7 @@ async fn step(
|
||||
let next: ReauthRequest = next.into();
|
||||
let next = next.build_uri()?;
|
||||
|
||||
Redirect::to(next).into_response()
|
||||
Redirect::to(&next.to_string()).into_response()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ pub(crate) async fn get(
|
||||
} else {
|
||||
let login = LoginRequest::default();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
Ok((cookie_jar.headers(), Redirect::to(login)).into_response())
|
||||
Ok((cookie_jar, Redirect::to(&login.to_string())).into_response())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ async fn render(
|
||||
.await
|
||||
.map_err(fancy_error(templates))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
|
||||
async fn start_email_verification(
|
||||
@@ -151,7 +151,7 @@ pub(crate) async fn post(
|
||||
} else {
|
||||
let login = LoginRequest::default();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
let form = cookie_jar
|
||||
|
||||
@@ -50,7 +50,7 @@ pub(crate) async fn get(
|
||||
} else {
|
||||
let login = LoginRequest::default();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
let active_sessions = count_active_sessions(&mut conn, &session.user)
|
||||
@@ -70,5 +70,5 @@ pub(crate) async fn get(
|
||||
.await
|
||||
.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ pub(crate) async fn get(
|
||||
} else {
|
||||
let login = LoginRequest::default();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
Ok((cookie_jar.headers(), Redirect::to(login)).into_response())
|
||||
Ok((cookie_jar, Redirect::to(&login.to_string())).into_response())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ async fn render(
|
||||
.await
|
||||
.map_err(fancy_error(templates))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
|
||||
pub(crate) async fn post(
|
||||
@@ -109,7 +109,7 @@ pub(crate) async fn post(
|
||||
} else {
|
||||
let login = LoginRequest::default();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
authenticate_session(&mut txn, &mut session, form.current_password)
|
||||
|
||||
@@ -50,5 +50,5 @@ pub async fn get(
|
||||
.await
|
||||
.map_err(fancy_error(templates))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)))
|
||||
Ok((cookie_jar, Html(content)))
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ impl LoginRequest {
|
||||
Uri::from_static("/")
|
||||
};
|
||||
|
||||
Ok(Redirect::to(uri))
|
||||
Ok(Redirect::to(&uri.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ pub(crate) async fn get(
|
||||
.await
|
||||
.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ pub(crate) async fn post(
|
||||
Ok(session_info) => {
|
||||
let cookie_jar = cookie_jar.set_session(&session_info);
|
||||
let reply = query.redirect().map_err(fancy_error(templates.clone()))?;
|
||||
Ok((cookie_jar.headers(), reply).into_response())
|
||||
Ok((cookie_jar, reply).into_response())
|
||||
}
|
||||
Err(e) => {
|
||||
let errored_form = match e {
|
||||
@@ -174,7 +174,7 @@ pub(crate) async fn post(
|
||||
.await
|
||||
.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ use axum::{
|
||||
extract::{Extension, Form},
|
||||
response::{IntoResponse, Redirect},
|
||||
};
|
||||
use hyper::Uri;
|
||||
use mas_axum_utils::{
|
||||
csrf::{CsrfExt, ProtectedForm},
|
||||
fancy_error, FancyError, PrivateCookieJar, SessionInfoExt,
|
||||
@@ -54,6 +53,5 @@ pub(crate) async fn post(
|
||||
|
||||
txn.commit().await.map_err(fancy_error(templates))?;
|
||||
|
||||
let to = Uri::from_static("/login");
|
||||
Ok((cookie_jar.headers(), Redirect::to(to)))
|
||||
Ok((cookie_jar, Redirect::to("/login")))
|
||||
}
|
||||
|
||||
@@ -63,13 +63,11 @@ impl ReauthRequest {
|
||||
}
|
||||
|
||||
fn redirect(self) -> Result<impl IntoResponse, anyhow::Error> {
|
||||
let uri = if let Some(action) = self.post_auth_action {
|
||||
action.build_uri()?
|
||||
if let Some(action) = self.post_auth_action {
|
||||
Ok(Redirect::to(&action.build_uri()?.to_string()))
|
||||
} else {
|
||||
Uri::from_static("/")
|
||||
};
|
||||
|
||||
Ok(Redirect::to(uri))
|
||||
Ok(Redirect::to("/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ pub(crate) async fn get(
|
||||
// PostAuthAction
|
||||
let login: LoginRequest = query.post_auth_action.into();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
let ctx = ReauthContext::default();
|
||||
@@ -125,7 +123,7 @@ pub(crate) async fn get(
|
||||
.await
|
||||
.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
|
||||
pub(crate) async fn post(
|
||||
@@ -155,7 +153,7 @@ pub(crate) async fn post(
|
||||
// PostAuthAction
|
||||
let login: LoginRequest = query.post_auth_action.into();
|
||||
let login = login.build_uri().map_err(fancy_error(templates.clone()))?;
|
||||
return Ok((cookie_jar.headers(), Redirect::to(login)).into_response());
|
||||
return Ok((cookie_jar, Redirect::to(&login.to_string())).into_response());
|
||||
};
|
||||
|
||||
// TODO: recover from errors here
|
||||
@@ -166,5 +164,5 @@ pub(crate) async fn post(
|
||||
txn.commit().await.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
let redirection = query.redirect().map_err(fancy_error(templates.clone()))?;
|
||||
Ok((cookie_jar.headers(), redirection).into_response())
|
||||
Ok((cookie_jar, redirection).into_response())
|
||||
}
|
||||
|
||||
@@ -64,13 +64,11 @@ impl RegisterRequest {
|
||||
}
|
||||
|
||||
fn redirect(self) -> Result<impl IntoResponse, anyhow::Error> {
|
||||
let uri = if let Some(action) = self.post_auth_action {
|
||||
action.build_uri()?
|
||||
if let Some(action) = self.post_auth_action {
|
||||
Ok(Redirect::to(&action.build_uri()?.to_string()))
|
||||
} else {
|
||||
Uri::from_static("/")
|
||||
};
|
||||
|
||||
Ok(Redirect::to(uri))
|
||||
Ok(Redirect::to("/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +127,7 @@ pub(crate) async fn get(
|
||||
.await
|
||||
.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)).into_response())
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,5 +162,5 @@ pub(crate) async fn post(
|
||||
|
||||
let cookie_jar = cookie_jar.set_session(&session);
|
||||
let reply = query.redirect().map_err(fancy_error(templates.clone()))?;
|
||||
Ok((cookie_jar.headers(), reply).into_response())
|
||||
Ok((cookie_jar, reply).into_response())
|
||||
}
|
||||
|
||||
@@ -66,5 +66,5 @@ pub(crate) async fn get(
|
||||
|
||||
txn.commit().await.map_err(fancy_error(templates.clone()))?;
|
||||
|
||||
Ok((cookie_jar.headers(), Html(content)))
|
||||
Ok((cookie_jar, Html(content)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user