| 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 |
scopes: vec![ |
| 28 |
"urn:ietf:params:jmap:core".to_string(), |
| 29 |
"urn:ietf:params:jmap:mail".to_string(), |
| 30 |
"urn:ietf:params:jmap:submission".to_string(), |
| 31 |
], |
| 32 |
uses_jmap: true, |
| 33 |
jmap_session_url: Some("https://api.fastmail.com/jmap/session".to_string()), |
| 34 |
imap_server: None, |
| 35 |
imap_port: None, |
| 36 |
smtp_server: None, |
| 37 |
smtp_port: None, |
| 38 |
userinfo_url: Some("https://api.fastmail.com/jmap/session".to_string()), |
| 39 |
email_json_path: vec!["username"], |
| 40 |
}, |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
impl OAuthProvider for FastmailProvider { |
| 46 |
fn id(&self) -> &'static str { |
| 47 |
"fastmail" |
| 48 |
} |
| 49 |
|
| 50 |
fn display_name(&self) -> &'static str { |
| 51 |
"Fastmail" |
| 52 |
} |
| 53 |
|
| 54 |
fn config(&self) -> &OAuthProviderConfig { |
| 55 |
&self.config |
| 56 |
} |
| 57 |
|
| 58 |
fn client_id(&self) -> &str { |
| 59 |
&self.client_id |
| 60 |
} |
| 61 |
|
| 62 |
fn client_auth_method(&self) -> ClientAuthMethod { |
| 63 |
|
| 64 |
ClientAuthMethod::ClientIdOnly |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
} |
| 69 |
|