mirror of
https://github.com/warp-tech/warpgate.git
synced 2025-09-10 16:44:41 +08:00
fixed #929 - support additional trusted OIDC audiences
This commit is contained in:
parent
92dc88558a
commit
75a2b8c5c6
2 changed files with 24 additions and 2 deletions
|
@ -59,6 +59,7 @@ pub enum SsoInternalProviderConfig {
|
||||||
client_secret: ClientSecret,
|
client_secret: ClientSecret,
|
||||||
issuer_url: IssuerUrl,
|
issuer_url: IssuerUrl,
|
||||||
scopes: Vec<String>,
|
scopes: Vec<String>,
|
||||||
|
additional_trusted_audiences: Option<Vec<String>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,4 +200,15 @@ impl SsoInternalProviderConfig {
|
||||||
SsoInternalProviderConfig::Apple { .. } => false,
|
SsoInternalProviderConfig::Apple { .. } => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn additional_trusted_audiences(&self) -> Option<&Vec<String>> {
|
||||||
|
match self {
|
||||||
|
SsoInternalProviderConfig::Custom {
|
||||||
|
additional_trusted_audiences,
|
||||||
|
..
|
||||||
|
} => additional_trusted_audiences.as_ref(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
use openidconnect::core::{CoreAuthenticationFlow, CoreClient, CoreProviderMetadata};
|
use openidconnect::core::{CoreAuthenticationFlow, CoreClient, CoreProviderMetadata};
|
||||||
use openidconnect::reqwest::async_http_client;
|
use openidconnect::reqwest::async_http_client;
|
||||||
|
@ -21,12 +22,21 @@ pub async fn make_client(config: &SsoInternalProviderConfig) -> Result<CoreClien
|
||||||
e => format!("{e}"),
|
e => format!("{e}"),
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
Ok(CoreClient::from_provider_metadata(
|
|
||||||
|
let client = CoreClient::from_provider_metadata(
|
||||||
metadata,
|
metadata,
|
||||||
config.client_id().clone(),
|
config.client_id().clone(),
|
||||||
Some(config.client_secret()?),
|
Some(config.client_secret()?),
|
||||||
)
|
)
|
||||||
.set_auth_type(config.auth_type()))
|
.set_auth_type(config.auth_type());
|
||||||
|
|
||||||
|
if let Some(trusted_audiences) = config.additional_trusted_audiences() {
|
||||||
|
client.id_token_verifier().set_other_audience_verifier_fn(|aud| {
|
||||||
|
trusted_audiences.contains(aud.deref())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SsoClient {
|
impl SsoClient {
|
||||||
|
|
Loading…
Add table
Reference in a new issue