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

Cache the upstream OAuth 2.0 provider metadata

This commit is contained in:
Quentin Gliech
2023-08-28 16:18:49 +02:00
parent 17e28f56c1
commit 07ca145174
8 changed files with 187 additions and 10 deletions

View File

@@ -48,6 +48,7 @@ use url::Url;
use crate::{
app_state::RepositoryError,
passwords::{Hasher, PasswordManager},
upstream_oauth2::cache::MetadataCache,
MatrixHomeserver,
};
@@ -67,6 +68,7 @@ pub(crate) struct TestState {
pub templates: Templates,
pub key_store: Keystore,
pub cookie_manager: CookieManager,
pub metadata_cache: MetadataCache,
pub encrypter: Encrypter,
pub url_builder: UrlBuilder,
pub homeserver: MatrixHomeserver,
@@ -106,6 +108,8 @@ impl TestState {
let cookie_manager =
CookieManager::derive_from("https://example.com".parse()?, &[0x42; 32]);
let metadata_cache = MetadataCache::new();
let password_manager = PasswordManager::new([(1, Hasher::argon2id(None))])?;
let homeserver = MatrixHomeserver::new("example.com".to_owned());
@@ -146,6 +150,7 @@ impl TestState {
templates,
key_store,
cookie_manager,
metadata_cache,
encrypter,
url_builder,
homeserver,
@@ -334,6 +339,12 @@ impl FromRef<TestState> for CookieManager {
}
}
impl FromRef<TestState> for MetadataCache {
fn from_ref(input: &TestState) -> Self {
input.metadata_cache.clone()
}
}
#[async_trait]
impl FromRequestParts<TestState> for BoxClock {
type Rejection = Infallible;