| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
use crate::oauth::provider::{ClientAuthMethod, OAuthProvider, OAuthProviderConfig}; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
pub struct FastmailProvider { |
| 15 |
client_id: String, |
| 16 |
config: OAuthProviderConfig, |
| 17 |
} |
| 18 |
|
| 19 |
impl FastmailProvider { |
| 20 |
|
| 21 |
pub fn new(client_id: impl Into<String>) -> Self { |
| 22 |
Self { |
| 23 |
client_id: client_id.into(), |
| 24 |
config: OAuthProviderConfig { |
| 25 |
auth_url: "https://api.fastmail.com/oauth/authorize".to_string(), |
| 26 |
token_url: "https://api.fastmail.com/oauth/refresh".to_string(), |
| 27 |
|
| 28 |
|
| 29 |
revoke_url: None, |
| 30 |
scopes: vec![ |
| 31 |
"urn:ietf:params:jmap:core".to_string(), |
| 32 |
"urn:ietf:params:jmap:mail".to_string(), |
| 33 |
"urn:ietf:params:jmap:submission".to_string(), |
| 34 |
], |
| 35 |
uses_jmap: true, |
| 36 |
jmap_session_url: Some("https://api.fastmail.com/jmap/session".to_string()), |
| 37 |
imap_server: None, |
| 38 |
imap_port: None, |
| 39 |
smtp_server: None, |
| 40 |
smtp_port: None, |
| 41 |
userinfo_url: Some("https://api.fastmail.com/jmap/session".to_string()), |
| 42 |
email_json_path: vec!["username"], |
| 43 |
}, |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
impl OAuthProvider for FastmailProvider { |
| 49 |
fn id(&self) -> &'static str { |
| 50 |
"fastmail" |
| 51 |
} |
| 52 |
|
| 53 |
fn display_name(&self) -> &'static str { |
| 54 |
"Fastmail" |
| 55 |
} |
| 56 |
|
| 57 |
fn config(&self) -> &OAuthProviderConfig { |
| 58 |
&self.config |
| 59 |
} |
| 60 |
|
| 61 |
fn client_id(&self) -> &str { |
| 62 |
&self.client_id |
| 63 |
} |
| 64 |
|
| 65 |
fn client_auth_method(&self) -> ClientAuthMethod { |
| 66 |
|
| 67 |
ClientAuthMethod::ClientIdOnly |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
} |
| 72 |
|