use super::Nonce;
use crate::algorithm::Algorithm;
use crate::engine::shared_config::SharedVerifyConfig;
#[derive(Debug, Clone)]
#[allow(dead_code)] pub struct VerifyConfig {
pub(crate) shared: SharedVerifyConfig,
pub(crate) expected_nonce: Nonce,
pub(crate) expected_access_token: Option<String>,
pub(crate) expected_authorization_code: Option<String>,
pub(crate) max_age: Option<i64>,
pub(crate) acr_values: Option<Vec<String>>,
}
impl VerifyConfig {
pub fn id_token(
issuer: impl Into<String>,
audience: impl Into<String>,
expected_nonce: Nonce,
) -> Self {
Self {
shared: SharedVerifyConfig::new(
issuer,
audience,
"JWT",
8 * 1024,
vec![Algorithm::EdDSA],
),
expected_nonce,
expected_access_token: None,
expected_authorization_code: None,
max_age: None,
acr_values: None,
}
}
#[must_use]
pub fn with_algorithms(mut self, algorithms: Vec<Algorithm>) -> Self {
self.shared.algorithms = algorithms;
self
}
#[must_use]
pub fn with_access_token_binding(mut self, access_token: impl Into<String>) -> Self {
self.expected_access_token = Some(access_token.into());
self
}
#[must_use]
pub fn with_authorization_code_binding(mut self, code: impl Into<String>) -> Self {
self.expected_authorization_code = Some(code.into());
self
}
#[must_use]
pub fn with_max_age(mut self, max_age: i64) -> Self {
self.max_age = Some(max_age);
self
}
#[must_use]
pub fn with_acr_values(mut self, acr_values: Vec<String>) -> Self {
self.acr_values = Some(acr_values);
self
}
}