pub struct ValidationConfig { /* private fields */ }
Expand description
Configures validation options for JWT issued by Google IAP.
§Validation Options
- By default, validates the audience claim against the provided list.
with_google_hosted_domain
: Additionally validates thehd
(hosted domain) claim.with_access_levels
: Additionally validates the access levels claim in the Google-specific payload.
Implementations§
Source§impl ValidationConfig
impl ValidationConfig
Sourcepub fn new<A, I>(audience: I) -> Self
pub fn new<A, I>(audience: I) -> Self
Creates a new validation config with the given audience.
By default, validates the audience claim against the provided list.
Sourcepub fn with_google_hosted_domain<H, I>(self, google_hosted_domain: I) -> Self
pub fn with_google_hosted_domain<H, I>(self, google_hosted_domain: I) -> Self
Validates that the hd claim is in the list of google hosted domains.
“If an account belongs to a hosted domain, the hd claim is provided to differentiate the domain the account is associated with.” - https://cloud.google.com/iap/docs/signed-headers-howto
Sourcepub fn with_access_levels<T: Into<String>>(
self,
access_levels: impl IntoIterator<Item = T>,
) -> Self
pub fn with_access_levels<T: Into<String>>( self, access_levels: impl IntoIterator<Item = T>, ) -> Self
Validates that the access levels claim contains all the access levels in the config.
Sourcepub async fn decode_and_validate<E: Error + Send + 'static>(
&self,
token: &str,
client: &impl PublicKeySource<Error = E>,
) -> Result<Claims, Error>
pub async fn decode_and_validate<E: Error + Send + 'static>( &self, token: &str, client: &impl PublicKeySource<Error = E>, ) -> Result<Claims, Error>
Decode and validate a jwt with respect to the IAP documentation: https://cloud.google.com/iap/docs/signed-headers-howto
Auto Trait Implementations§
impl Freeze for ValidationConfig
impl RefUnwindSafe for ValidationConfig
impl Send for ValidationConfig
impl Sync for ValidationConfig
impl Unpin for ValidationConfig
impl UnwindSafe for ValidationConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more