From 9888ac406294c18c79df411bbf23fc3e9142798c Mon Sep 17 00:00:00 2001 From: Simon Goller Date: Wed, 5 Jun 2024 16:36:31 +0200 Subject: [PATCH] Display some more OIDC information --- rest/src/lib.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/rest/src/lib.rs b/rest/src/lib.rs index be7a0e0..09dd96b 100644 --- a/rest/src/lib.rs +++ b/rest/src/lib.rs @@ -191,12 +191,27 @@ pub async fn login() -> Redirect { #[cfg(feature = "oidc")] pub async fn auth_info(claims: Option>) -> Response { if let Some(oidc_claims) = claims { - let nickname = oidc_claims - .nickname() - .map(|s| s.iter().next().map(|s| s.1.as_str().to_string())) - .unwrap_or_else(|| Some("NickNotSet".to_string())) - .unwrap_or_else(|| "NickEmpty".to_string()); - let body = format!("Hello, {}! ", nickname); + let username = oidc_claims + .preferred_username() + .map(|s| s.as_str().to_string()) + .unwrap_or_else(|| "NoUsername".to_string()); + let email = oidc_claims + .email() + .map(|s| s.as_str().to_string()) + .unwrap_or_else(|| "MailNotSet".to_string()); + let name = oidc_claims + .name() + .map(|s| { + s.iter() + .next() + .map(|s| s.1.as_str().to_string()) + .unwrap_or_else(|| "NoLocalizedName".to_string()) + }) + .unwrap_or_else(|| "NameNotSet".to_string()); + let body = format!( + "Hello, {}! Your email is {} and your username is {}", + name, email, username + ); Response::builder() .status(200) .body(Body::new(body))