From c13992e1090e343506c707a5448e0b22b0e0400a Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sat, 15 Apr 2023 11:25:34 +0200 Subject: [PATCH] Help debug Webauthn configuration --- src/data/webauthn_manager.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/data/webauthn_manager.rs b/src/data/webauthn_manager.rs index bcf5f78..8474737 100644 --- a/src/data/webauthn_manager.rs +++ b/src/data/webauthn_manager.rs @@ -56,19 +56,28 @@ pub struct WebAuthManager { impl WebAuthManager { pub fn init(conf: &AppConfig) -> Self { + let rp_id = conf + .domain_name() + .split_once(':') + .map(|s| s.0) + .unwrap_or_else(|| conf.domain_name()); + + let rp_origin = + url::Url::parse(&conf.website_origin).expect("Failed to parse configuration origin!"); + + log::debug!( + "rp_id={} rp_origin={} rp_origin_domain={:?}", + rp_id, + rp_origin, + rp_origin.domain() + ); + Self { - core: WebauthnBuilder::new( - conf.domain_name() - .split_once(':') - .map(|s| s.0) - .unwrap_or_else(|| conf.domain_name()), - &url::Url::parse(&conf.website_origin) - .expect("Failed to parse configuration origin!"), - ) - .expect("Invalid Webauthn configuration") - .rp_name(APP_NAME) - .build() - .expect("Failed to build webauthn"), + core: WebauthnBuilder::new(rp_id, &rp_origin) + .expect("Invalid Webauthn configuration") + .rp_name(APP_NAME) + .build() + .expect("Failed to build webauthn"), crypto_wrapper: CryptoWrapper::new_random(), } }