use url::Url;
use axess_factors::ZeroizedString;
#[derive(Debug)]
pub struct DelegatedProvider {
pub name: String,
pub authorization_endpoint: Url,
pub token_endpoint: Url,
pub client_id: String,
pub client_secret: ZeroizedString,
pub redirect_uri: Url,
pub default_scopes: Vec<String>,
}
impl DelegatedProvider {
pub fn new(
name: impl Into<String>,
authorization_endpoint: Url,
token_endpoint: Url,
client_id: impl Into<String>,
client_secret: impl Into<ZeroizedString>,
redirect_uri: Url,
) -> Self {
Self {
name: name.into(),
authorization_endpoint,
token_endpoint,
client_id: client_id.into(),
client_secret: client_secret.into(),
redirect_uri,
default_scopes: Vec::new(),
}
}
pub fn with_default_scopes<I, S>(mut self, scopes: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
self.default_scopes = scopes.into_iter().map(Into::into).collect();
self
}
}