log precise SSO discovery errors

This commit is contained in:
Eugene Pankov 2022-10-30 10:52:33 +01:00
parent 0c3567b300
commit 055a12ba32
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4

View file

@ -2,7 +2,10 @@ use std::borrow::Cow;
use openidconnect::core::{CoreAuthenticationFlow, CoreClient, CoreProviderMetadata}; use openidconnect::core::{CoreAuthenticationFlow, CoreClient, CoreProviderMetadata};
use openidconnect::reqwest::async_http_client; use openidconnect::reqwest::async_http_client;
use openidconnect::{CsrfToken, Nonce, PkceCodeChallenge, RedirectUrl, Scope}; use openidconnect::{
CsrfToken, DiscoveryError, Nonce, PkceCodeChallenge, RedirectUrl,
Scope,
};
use crate::config::SsoInternalProviderConfig; use crate::config::SsoInternalProviderConfig;
use crate::request::SsoLoginRequest; use crate::request::SsoLoginRequest;
@ -15,7 +18,12 @@ pub struct SsoClient {
pub async fn make_client(config: &SsoInternalProviderConfig) -> Result<CoreClient, SsoError> { pub async fn make_client(config: &SsoInternalProviderConfig) -> Result<CoreClient, SsoError> {
let metadata = CoreProviderMetadata::discover_async(config.issuer_url()?, async_http_client) let metadata = CoreProviderMetadata::discover_async(config.issuer_url()?, async_http_client)
.await .await
.map_err(|e| SsoError::Discovery(format!("{e}")))?; .map_err(|e| {
SsoError::Discovery(match e {
DiscoveryError::Request(inner) => format!("Request error: {}", inner),
e => format!("{e}"),
})
})?;
Ok(CoreClient::from_provider_metadata( Ok(CoreClient::from_provider_metadata(
metadata, metadata,
config.client_id().clone(), config.client_id().clone(),