Add CORS headers on OpenID configuration endpoint
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2025-02-21 11:59:32 +01:00
parent 4a248e84ac
commit a73ad4bf41
2 changed files with 333 additions and 366 deletions

635
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -50,37 +50,39 @@ pub async fn get_configuration(req: HttpRequest) -> impl Responder {
host host
); );
HttpResponse::Ok().json(OpenIDConfig { HttpResponse::Ok()
issuer: AppConfig::get().website_origin.clone(), .insert_header(("access-control-allow-origin", "*"))
authorization_endpoint: AppConfig::get().full_url(AUTHORIZE_URI), .json(OpenIDConfig {
token_endpoint: curr_origin.clone() + TOKEN_URI, issuer: AppConfig::get().website_origin.clone(),
userinfo_endpoint: Some(curr_origin.clone() + USERINFO_URI), authorization_endpoint: AppConfig::get().full_url(AUTHORIZE_URI),
jwks_uri: curr_origin + CERT_URI, token_endpoint: curr_origin.clone() + TOKEN_URI,
scopes_supported: Some(vec![ userinfo_endpoint: Some(curr_origin.clone() + USERINFO_URI),
"openid".to_string(), jwks_uri: curr_origin + CERT_URI,
"profile".to_string(), scopes_supported: Some(vec![
"email".to_string(), "openid".to_string(),
]), "profile".to_string(),
response_types_supported: vec![ "email".to_string(),
"code".to_string(), ]),
"id_token".to_string(), response_types_supported: vec![
"token id_token".to_string(), "code".to_string(),
], "id_token".to_string(),
subject_types_supported: vec!["public".to_string()], "token id_token".to_string(),
id_token_signing_alg_values_supported: vec!["RS256".to_string()], ],
token_endpoint_auth_methods_supported: Some(vec![ subject_types_supported: vec!["public".to_string()],
"client_secret_post".to_string(), id_token_signing_alg_values_supported: vec!["RS256".to_string()],
"client_secret_basic".to_string(), token_endpoint_auth_methods_supported: Some(vec![
]), "client_secret_post".to_string(),
claims_supported: Some(vec![ "client_secret_basic".to_string(),
"sub".to_string(), ]),
"name".to_string(), claims_supported: Some(vec![
"given_name".to_string(), "sub".to_string(),
"family_name".to_string(), "name".to_string(),
"email".to_string(), "given_name".to_string(),
]), "family_name".to_string(),
code_challenge_methods_supported: Some(vec!["plain".to_string(), "S256".to_string()]), "email".to_string(),
}) ]),
code_challenge_methods_supported: Some(vec!["plain".to_string(), "S256".to_string()]),
})
} }
#[derive(serde::Deserialize, Debug)] #[derive(serde::Deserialize, Debug)]