use std::sync::Arc;
use super::epoch_revocation::EpochRevocation;
use super::replay_defense::ReplayDefense;
use super::session_revocation::SessionRevocation;
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) replay: Option<Arc<dyn ReplayDefense>>,
pub(crate) session: Option<Arc<dyn SessionRevocation>>,
pub(crate) epoch: Option<Arc<dyn EpochRevocation>>,
}
impl VerifyConfig {
pub fn access_token(issuer: impl Into<String>, audience: impl Into<String>) -> Self {
Self {
shared: SharedVerifyConfig::new(
issuer,
audience,
"at+jwt",
8 * 1024,
vec![Algorithm::EdDSA],
),
replay: None,
session: None,
epoch: None,
}
}
#[must_use]
pub fn with_algorithms(mut self, algorithms: Vec<Algorithm>) -> Self {
self.shared.algorithms = algorithms;
self
}
#[must_use]
pub fn with_replay_defense(mut self, port: Arc<dyn ReplayDefense>) -> Self {
self.replay = Some(port);
self
}
#[must_use]
pub fn with_session_revocation(mut self, port: Arc<dyn SessionRevocation>) -> Self {
self.session = Some(port);
self
}
#[must_use]
pub fn with_epoch_revocation(mut self, port: Arc<dyn EpochRevocation>) -> Self {
self.epoch = Some(port);
self
}
}