1use crate::internals::proto::{
2 Oidc,
3 SecretString,
4};
5
6#[derive(Clone, Default)]
10pub struct OidcOptions {
11 issuer_url: String,
12 client_id: String,
13 client_secret: SecretString,
14 allow_emails: Vec<String>,
15 allow_domains: Vec<String>,
16 scopes: Vec<String>,
17}
18
19impl OidcOptions {
20 pub fn new(
22 issuer_url: impl Into<String>,
23 client_id: impl Into<String>,
24 client_secret: impl Into<String>,
25 ) -> Self {
26 OidcOptions {
27 issuer_url: issuer_url.into(),
28 client_id: client_id.into(),
29 client_secret: client_secret.into().into(),
30 ..Default::default()
31 }
32 }
33
34 pub fn allow_email(&mut self, email: impl Into<String>) -> &mut Self {
36 self.allow_emails.push(email.into());
37 self
38 }
39 pub fn allow_domain(&mut self, domain: impl Into<String>) -> &mut Self {
41 self.allow_domains.push(domain.into());
42 self
43 }
44 pub fn scope(&mut self, scope: impl Into<String>) -> &mut Self {
46 self.scopes.push(scope.into());
47 self
48 }
49}
50
51impl From<OidcOptions> for Oidc {
53 fn from(o: OidcOptions) -> Self {
54 Oidc {
55 issuer_url: o.issuer_url,
56 client_id: o.client_id,
57 client_secret: o.client_secret,
58 sealed_client_secret: Default::default(), allow_emails: o.allow_emails,
60 allow_domains: o.allow_domains,
61 scopes: o.scopes,
62 }
63 }
64}