#[derive(Debug, Clone)]
pub struct AuthConfig {
pub secret: Vec<u8>,
pub issuer: Option<String>,
pub audience: Option<String>,
pub bearer_token: bool,
pub session_cookie_name: Option<String>,
}
impl AuthConfig {
pub fn new(secret: impl Into<Vec<u8>>) -> Self {
Self {
secret: secret.into(),
issuer: None,
audience: None,
bearer_token: true,
session_cookie_name: None,
}
}
pub fn with_session_cookie(mut self, cookie_name: impl Into<String>) -> Self {
self.session_cookie_name = Some(cookie_name.into());
self
}
pub fn with_issuer(mut self, issuer: impl Into<String>) -> Self {
self.issuer = Some(issuer.into());
self
}
pub fn with_audience(mut self, audience: impl Into<String>) -> Self {
self.audience = Some(audience.into());
self
}
pub fn enable_bearer(mut self, yes: bool) -> Self {
self.bearer_token = yes;
self
}
}