1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Split compat and api routers

This commit is contained in:
Quentin Gliech
2022-05-17 10:20:13 +02:00
parent 01cdb9a02a
commit 076d4b8d13

View File

@@ -28,6 +28,7 @@ use axum::{
routing::{get, on, post, MethodFilter}, routing::{get, on, post, MethodFilter},
Router, Router,
}; };
use headers::HeaderName;
use hyper::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, CONTENT_LANGUAGE, CONTENT_TYPE}; use hyper::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, CONTENT_LANGUAGE, CONTENT_TYPE};
use mas_config::{Encrypter, MatrixConfig}; use mas_config::{Encrypter, MatrixConfig};
use mas_email::Mailer; use mas_email::Mailer;
@@ -97,6 +98,21 @@ where
mas_router::OAuth2RegistrationEndpoint::route(), mas_router::OAuth2RegistrationEndpoint::route(),
post(self::oauth2::registration::post), post(self::oauth2::registration::post),
) )
.layer(
CorsLayer::new()
.allow_origin(Any)
.allow_methods(Any)
.allow_otel_headers([
AUTHORIZATION,
ACCEPT,
ACCEPT_LANGUAGE,
CONTENT_LANGUAGE,
CONTENT_TYPE,
])
.max_age(Duration::from_secs(60 * 60)),
);
let compat_router = Router::new()
.route( .route(
mas_router::CompatLogin::route(), mas_router::CompatLogin::route(),
get(self::compat::login::get).post(self::compat::login::post), get(self::compat::login::get).post(self::compat::login::post),
@@ -115,6 +131,7 @@ where
ACCEPT_LANGUAGE, ACCEPT_LANGUAGE,
CONTENT_LANGUAGE, CONTENT_LANGUAGE,
CONTENT_TYPE, CONTENT_TYPE,
HeaderName::from_static("x-requested-with"),
]) ])
.max_age(Duration::from_secs(60 * 60)), .max_age(Duration::from_secs(60 * 60)),
); );
@@ -185,6 +202,7 @@ where
human_router human_router
.merge(api_router) .merge(api_router)
.merge(compat_router)
.layer(Extension(pool.clone())) .layer(Extension(pool.clone()))
.layer(Extension(templates.clone())) .layer(Extension(templates.clone()))
.layer(Extension(key_store.clone())) .layer(Extension(key_store.clone()))