You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-06 06:02:40 +03:00
Fix request handling when the cookie header is not there
This commit is contained in:
@@ -26,7 +26,7 @@ use headers::{Header, HeaderValue, SetCookie};
|
|||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use warp::{
|
use warp::{
|
||||||
reject::{MissingCookie, Reject},
|
reject::{InvalidHeader, MissingCookie, Reject},
|
||||||
Filter, Rejection, Reply,
|
Filter, Rejection, Reply,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,6 +120,8 @@ where
|
|||||||
{
|
{
|
||||||
encrypted(options)
|
encrypted(options)
|
||||||
.map(Some)
|
.map(Some)
|
||||||
|
.recover(none_on_error::<T, InvalidHeader>)
|
||||||
|
.unify()
|
||||||
.recover(none_on_error::<T, MissingCookie>)
|
.recover(none_on_error::<T, MissingCookie>)
|
||||||
.unify()
|
.unify()
|
||||||
.recover(none_on_error::<T, CookieDecryptionError<T>>)
|
.recover(none_on_error::<T, CookieDecryptionError<T>>)
|
||||||
|
@@ -19,7 +19,7 @@ use sqlx::{pool::PoolConnection, Executor, PgPool, Postgres};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use warp::{
|
use warp::{
|
||||||
reject::{MissingCookie, Reject},
|
reject::{InvalidHeader, MissingCookie, Reject},
|
||||||
Filter, Rejection,
|
Filter, Rejection,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,6 +134,12 @@ async fn recover<T>(rejection: Rejection) -> Result<T, Rejection> {
|
|||||||
// propagated
|
// propagated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(e) = rejection.find::<InvalidHeader>() {
|
||||||
|
if e.name() == "cookie" {
|
||||||
|
return Err(warp::reject::custom(SessionLoadError::MissingCookie));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(_e) = rejection.find::<MissingCookie>() {
|
if let Some(_e) = rejection.find::<MissingCookie>() {
|
||||||
return Err(warp::reject::custom(SessionLoadError::MissingCookie));
|
return Err(warp::reject::custom(SessionLoadError::MissingCookie));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user