1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Refactor the upstream link provider template logic

Also adds tests for new account registration through an upstream oauth2
provider
This commit is contained in:
Quentin Gliech
2023-11-13 12:29:01 +01:00
parent 9c94e11e68
commit 89420a2cfc
9 changed files with 560 additions and 153 deletions

View File

@@ -55,6 +55,22 @@ impl CookieManager {
let key = Key::derive_from(key);
Self::new(base_url, key)
}
#[must_use]
pub fn cookie_jar(&self) -> CookieJar {
let inner = PrivateCookieJar::new(self.key.clone());
let options = self.options.clone();
CookieJar { inner, options }
}
#[must_use]
pub fn cookie_jar_from_headers(&self, headers: &http::HeaderMap) -> CookieJar {
let inner = PrivateCookieJar::from_headers(headers, self.key.clone());
let options = self.options.clone();
CookieJar { inner, options }
}
}
#[async_trait]
@@ -67,10 +83,7 @@ where
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
let cookie_manager = CookieManager::from_ref(state);
let inner = PrivateCookieJar::from_headers(&parts.headers, cookie_manager.key.clone());
let options = cookie_manager.options.clone();
Ok(CookieJar { inner, options })
Ok(cookie_manager.cookie_jar_from_headers(&parts.headers))
}
}