1use crate::internals::proto::{
2 Oauth,
3 SecretString,
4};
5
6#[derive(Clone, Default)]
10pub struct OauthOptions {
11 provider: String,
13
14 client_id: String,
16 client_secret: SecretString,
18
19 allow_emails: Vec<String>,
21 allow_domains: Vec<String>,
23 scopes: Vec<String>,
25}
26
27impl OauthOptions {
28 pub fn new(provider: impl Into<String>) -> Self {
30 OauthOptions {
31 provider: provider.into(),
32 ..Default::default()
33 }
34 }
35
36 pub fn client_id(&mut self, id: impl Into<String>) -> &mut Self {
38 self.client_id = id.into();
39 self
40 }
41
42 pub fn client_secret(&mut self, secret: impl Into<String>) -> &mut Self {
44 self.client_secret = SecretString::from(secret.into());
45 self
46 }
47
48 pub fn allow_email(&mut self, email: impl Into<String>) -> &mut Self {
50 self.allow_emails.push(email.into());
51 self
52 }
53 pub fn allow_domain(&mut self, domain: impl Into<String>) -> &mut Self {
55 self.allow_domains.push(domain.into());
56 self
57 }
58 pub fn scope(&mut self, scope: impl Into<String>) -> &mut Self {
60 self.scopes.push(scope.into());
61 self
62 }
63}
64
65impl From<OauthOptions> for Oauth {
67 fn from(o: OauthOptions) -> Self {
68 Oauth {
69 provider: o.provider,
70 client_id: o.client_id,
71 client_secret: o.client_secret,
72 sealed_client_secret: Default::default(), allow_emails: o.allow_emails,
74 allow_domains: o.allow_domains,
75 scopes: o.scopes,
76 }
77 }
78}