mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
make use of new oauth2-authorizer information in the provider-db
This commit is contained in:
@@ -9,6 +9,8 @@ use serde::Deserialize;
|
|||||||
|
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::dc_tools::*;
|
use crate::dc_tools::*;
|
||||||
|
use crate::provider;
|
||||||
|
use crate::provider::Oauth2Authorizer;
|
||||||
|
|
||||||
const OAUTH2_GMAIL: Oauth2 = Oauth2 {
|
const OAUTH2_GMAIL: Oauth2 = Oauth2 {
|
||||||
// see https://developers.google.com/identity/protocols/OAuth2InstalledApp
|
// see https://developers.google.com/identity/protocols/OAuth2InstalledApp
|
||||||
@@ -276,8 +278,12 @@ impl Oauth2 {
|
|||||||
.find('@')
|
.find('@')
|
||||||
.map(|index| addr_normalized.split_at(index + 1).1)
|
.map(|index| addr_normalized.split_at(index + 1).1)
|
||||||
{
|
{
|
||||||
if let Some(provider) = Oauth2::lookup_whitelist(domain) {
|
if let Some(provider) = provider::get_provider_info(&addr_normalized) {
|
||||||
Some(provider)
|
match &provider.oauth2_authorizer {
|
||||||
|
Some(Oauth2Authorizer::Gmail) => Some(OAUTH2_GMAIL),
|
||||||
|
Some(Oauth2Authorizer::Yandex) => Some(OAUTH2_YANDEX),
|
||||||
|
None => None, // provider known to not support oauth2, no mx-lookup required
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Oauth2::lookup_mx(domain).await
|
Oauth2::lookup_mx(domain).await
|
||||||
}
|
}
|
||||||
@@ -286,16 +292,6 @@ impl Oauth2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_whitelist(domain: impl AsRef<str>) -> Option<Self> {
|
|
||||||
let domain = domain.as_ref();
|
|
||||||
match domain {
|
|
||||||
"gmail.com" | "googlemail.com" => Some(OAUTH2_GMAIL),
|
|
||||||
"yandex.com" | "yandex.by" | "yandex.kz" | "yandex.ru" | "yandex.ua" | "ya.ru"
|
|
||||||
| "narod.ru" => Some(OAUTH2_YANDEX),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn lookup_mx(domain: impl AsRef<str>) -> Option<Self> {
|
async fn lookup_mx(domain: impl AsRef<str>) -> Option<Self> {
|
||||||
if let Ok(resolver) = resolver(
|
if let Ok(resolver) = resolver(
|
||||||
config::ResolverConfig::default(),
|
config::ResolverConfig::default(),
|
||||||
|
|||||||
Reference in New Issue
Block a user