-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathK9OAuthConfigurationFactory.kt
More file actions
118 lines (109 loc) · 5.21 KB
/
K9OAuthConfigurationFactory.kt
File metadata and controls
118 lines (109 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package app.k9mail.auth
import com.fsck.k9.BuildConfig
import net.thunderbird.core.common.oauth.OAuthConfiguration
import net.thunderbird.core.common.oauth.OAuthConfigurationFactory
@Suppress("ktlint:standard:max-line-length")
class K9OAuthConfigurationFactory : OAuthConfigurationFactory {
override fun createConfigurations(): Map<List<String>, OAuthConfiguration> {
return mapOf(
createAolConfiguration(),
createFastmailConfiguration(),
createGmailConfiguration(),
createMicrosoftConfiguration(),
createYahooConfiguration(),
createThundermailConfiguration(),
createThundermailStageConfiguration(),
)
}
private fun createAolConfiguration(): Pair<List<String>, OAuthConfiguration> {
return listOf(
"imap.aol.com",
"smtp.aol.com",
) to OAuthConfiguration(
clientId = "dj0yJmk9dUNqYXZhYWxOYkdRJmQ9WVdrOU1YQnZVRFZoY1ZrbWNHbzlNQT09JnM9Y29uc3VtZXJzZWNyZXQmc3Y9MCZ4PWIw",
scopes = listOf("mail-w"),
authorizationEndpoint = "https://api.login.aol.com/oauth2/request_auth",
tokenEndpoint = "https://api.login.aol.com/oauth2/get_token",
redirectUri = "${BuildConfig.APPLICATION_ID}://oauth2redirect",
)
}
private fun createFastmailConfiguration(): Pair<List<String>, OAuthConfiguration> {
return listOf(
"imap.fastmail.com",
"smtp.fastmail.com",
) to OAuthConfiguration(
clientId = "353641ae",
scopes = listOf("https://www.fastmail.com/dev/protocol-imap", "https://www.fastmail.com/dev/protocol-smtp"),
authorizationEndpoint = "https://api.fastmail.com/oauth/authorize",
tokenEndpoint = "https://api.fastmail.com/oauth/refresh",
redirectUri = "${BuildConfig.APPLICATION_ID}://oauth2redirect",
)
}
private fun createGmailConfiguration(): Pair<List<String>, OAuthConfiguration> {
return listOf(
"imap.gmail.com",
"imap.googlemail.com",
"smtp.gmail.com",
"smtp.googlemail.com",
) to OAuthConfiguration(
clientId = "262622259280-hhmh92rhklkg2k1tjil69epo0o9a12jm.apps.googleusercontent.com",
scopes = listOf("https://mail.google.com/"),
authorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth",
tokenEndpoint = "https://oauth2.googleapis.com/token",
redirectUri = "${BuildConfig.APPLICATION_ID}:/oauth2redirect",
)
}
private fun createMicrosoftConfiguration(): Pair<List<String>, OAuthConfiguration> {
return listOf(
"outlook.office365.com",
"smtp.office365.com",
"smtp-mail.outlook.com",
) to OAuthConfiguration(
clientId = "e647013a-ada4-4114-b419-e43d250f99c5",
scopes = listOf(
"profile",
"openid",
"email",
"https://outlook.office.com/IMAP.AccessAsUser.All",
"https://outlook.office.com/SMTP.Send",
"offline_access",
),
authorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
tokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token",
redirectUri = "msauth://com.fsck.k9/Dx8yUsuhyU3dYYba1aA16Wxu5eM%3D",
)
}
private fun createYahooConfiguration(): Pair<List<String>, OAuthConfiguration> {
return listOf(
"imap.mail.yahoo.com",
"smtp.mail.yahoo.com",
) to OAuthConfiguration(
clientId = "dj0yJmk9aHNUb3d2MW5TQnpRJmQ9WVdrOWVYbHpaRWM0YkdnbWNHbzlNQT09JnM9Y29uc3VtZXJzZWNyZXQmc3Y9MCZ4PWIz",
scopes = listOf("mail-w"),
authorizationEndpoint = "https://api.login.yahoo.com/oauth2/request_auth",
tokenEndpoint = "https://api.login.yahoo.com/oauth2/get_token",
redirectUri = "${BuildConfig.APPLICATION_ID}://oauth2redirect",
)
}
private fun createThundermailConfiguration(): Pair<List<String>, OAuthConfiguration> =
listOf(
"mail.tb.pro",
"mail.thundermail.com",
) to OAuthConfiguration(
clientId = "mobile-android-k9mail",
scopes = listOf("openid", "profile", "email", "offline_access"),
authorizationEndpoint = "https://auth.tb.pro/realms/tbpro/protocol/openid-connect/auth",
tokenEndpoint = "https://auth.tb.pro/realms/tbpro/protocol/openid-connect/token",
redirectUri = "${BuildConfig.APPLICATION_ID}://oauth2redirect",
)
private fun createThundermailStageConfiguration(): Pair<List<String>, OAuthConfiguration> =
listOf(
"mail.stage-thundermail.com",
) to OAuthConfiguration(
clientId = "mobile-android-k9mail",
scopes = listOf("openid", "profile", "email", "offline_access"),
authorizationEndpoint = "https://auth-stage.tb.pro/realms/tbpro/protocol/openid-connect/auth",
tokenEndpoint = "https://auth-stage.tb.pro/realms/tbpro/protocol/openid-connect/token",
redirectUri = "${BuildConfig.APPLICATION_ID}://oauth2redirect",
)
}