mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Resolve MX domain only once per OAuth2 provider
Currently we have only one provider in the list, so there is no difference, but more providers (e.g. Yandex.Connect) may be added later.
This commit is contained in:
committed by
link2xt
parent
78fd0c285b
commit
30c334d887
@@ -297,16 +297,16 @@ impl Oauth2 {
|
||||
)
|
||||
.await
|
||||
{
|
||||
for provider in OAUTH2_PROVIDERS.iter() {
|
||||
if let Some(pattern) = provider.mx_pattern {
|
||||
let re = Regex::new(pattern).unwrap();
|
||||
let mut fqdn: String = String::from(domain.as_ref());
|
||||
if !fqdn.ends_with('.') {
|
||||
fqdn.push('.');
|
||||
}
|
||||
|
||||
let mut fqdn: String = String::from(domain.as_ref());
|
||||
if !fqdn.ends_with('.') {
|
||||
fqdn.push('.');
|
||||
}
|
||||
if let Ok(res) = resolver.mx_lookup(fqdn).await {
|
||||
for provider in OAUTH2_PROVIDERS.iter() {
|
||||
if let Some(pattern) = provider.mx_pattern {
|
||||
let re = Regex::new(pattern).unwrap();
|
||||
|
||||
if let Ok(res) = resolver.mx_lookup(fqdn).await {
|
||||
for rr in res.iter() {
|
||||
if re.is_match(&rr.exchange().to_lowercase().to_utf8()) {
|
||||
return Some(provider.clone());
|
||||
|
||||
Reference in New Issue
Block a user