Open source third party OIDC support
This commit is contained in:
@@ -8,7 +8,6 @@ pub mod imap;
|
|||||||
pub mod internal;
|
pub mod internal;
|
||||||
pub mod ldap;
|
pub mod ldap;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
pub mod oidc;
|
pub mod oidc;
|
||||||
pub mod smtp;
|
pub mod smtp;
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: LicenseRef-SEL
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||||
*
|
|
||||||
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
|
|
||||||
* is NOT open source software.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: LicenseRef-SEL
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||||
*
|
|
||||||
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
|
|
||||||
* is NOT open source software.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use ahash::HashMap;
|
use ahash::HashMap;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: LicenseRef-SEL
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||||
*
|
|
||||||
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
|
|
||||||
* is NOT open source software.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ use ahash::AHashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{
|
backend::{
|
||||||
imap::ImapDirectory, ldap::LdapDirectory, memory::MemoryDirectory, smtp::SmtpDirectory,
|
imap::ImapDirectory, ldap::LdapDirectory, memory::MemoryDirectory, oidc::OpenIdDirectory,
|
||||||
sql::SqlDirectory,
|
smtp::SmtpDirectory, sql::SqlDirectory,
|
||||||
},
|
},
|
||||||
Directories, Directory, DirectoryInner,
|
Directories, Directory, DirectoryInner,
|
||||||
};
|
};
|
||||||
@@ -84,13 +84,8 @@ impl Directories {
|
|||||||
"memory" => MemoryDirectory::from_config(config, prefix, data_store.clone())
|
"memory" => MemoryDirectory::from_config(config, prefix, data_store.clone())
|
||||||
.await
|
.await
|
||||||
.map(DirectoryInner::Memory),
|
.map(DirectoryInner::Memory),
|
||||||
#[cfg(feature = "enterprise")]
|
"oidc" => OpenIdDirectory::from_config(config, prefix, data_store.clone())
|
||||||
"oidc" => crate::backend::oidc::OpenIdDirectory::from_config(
|
.map(DirectoryInner::OpenId),
|
||||||
config,
|
|
||||||
prefix,
|
|
||||||
data_store.clone(),
|
|
||||||
)
|
|
||||||
.map(DirectoryInner::OpenId),
|
|
||||||
unknown => {
|
unknown => {
|
||||||
let err = format!("Unknown directory type: {unknown:?}");
|
let err = format!("Unknown directory type: {unknown:?}");
|
||||||
config.new_parse_error(("directory", id, "type"), err);
|
config.new_parse_error(("directory", id, "type"), err);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.query(by).await,
|
DirectoryInner::Imap(store) => store.query(by).await,
|
||||||
DirectoryInner::Smtp(store) => store.query(by).await,
|
DirectoryInner::Smtp(store) => store.query(by).await,
|
||||||
DirectoryInner::Memory(store) => store.query(by).await,
|
DirectoryInner::Memory(store) => store.query(by).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.query(by, return_member_of).await,
|
DirectoryInner::OpenId(store) => store.query(by, return_member_of).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
@@ -38,7 +37,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.email_to_id(address).await,
|
DirectoryInner::Imap(store) => store.email_to_id(address).await,
|
||||||
DirectoryInner::Smtp(store) => store.email_to_id(address).await,
|
DirectoryInner::Smtp(store) => store.email_to_id(address).await,
|
||||||
DirectoryInner::Memory(store) => store.email_to_id(address).await,
|
DirectoryInner::Memory(store) => store.email_to_id(address).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.email_to_id(address).await,
|
DirectoryInner::OpenId(store) => store.email_to_id(address).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
@@ -59,7 +57,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.is_local_domain(domain).await,
|
DirectoryInner::Imap(store) => store.is_local_domain(domain).await,
|
||||||
DirectoryInner::Smtp(store) => store.is_local_domain(domain).await,
|
DirectoryInner::Smtp(store) => store.is_local_domain(domain).await,
|
||||||
DirectoryInner::Memory(store) => store.is_local_domain(domain).await,
|
DirectoryInner::Memory(store) => store.is_local_domain(domain).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.is_local_domain(domain).await,
|
DirectoryInner::OpenId(store) => store.is_local_domain(domain).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())?;
|
.caused_by(trc::location!())?;
|
||||||
@@ -87,7 +84,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.rcpt(email).await,
|
DirectoryInner::Imap(store) => store.rcpt(email).await,
|
||||||
DirectoryInner::Smtp(store) => store.rcpt(email).await,
|
DirectoryInner::Smtp(store) => store.rcpt(email).await,
|
||||||
DirectoryInner::Memory(store) => store.rcpt(email).await,
|
DirectoryInner::Memory(store) => store.rcpt(email).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.rcpt(email).await,
|
DirectoryInner::OpenId(store) => store.rcpt(email).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())?;
|
.caused_by(trc::location!())?;
|
||||||
@@ -108,7 +104,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.vrfy(address).await,
|
DirectoryInner::Imap(store) => store.vrfy(address).await,
|
||||||
DirectoryInner::Smtp(store) => store.vrfy(address).await,
|
DirectoryInner::Smtp(store) => store.vrfy(address).await,
|
||||||
DirectoryInner::Memory(store) => store.vrfy(address).await,
|
DirectoryInner::Memory(store) => store.vrfy(address).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.vrfy(address).await,
|
DirectoryInner::OpenId(store) => store.vrfy(address).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
@@ -122,7 +117,6 @@ impl Directory {
|
|||||||
DirectoryInner::Imap(store) => store.expn(address).await,
|
DirectoryInner::Imap(store) => store.expn(address).await,
|
||||||
DirectoryInner::Smtp(store) => store.expn(address).await,
|
DirectoryInner::Smtp(store) => store.expn(address).await,
|
||||||
DirectoryInner::Memory(store) => store.expn(address).await,
|
DirectoryInner::Memory(store) => store.expn(address).await,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(store) => store.expn(address).await,
|
DirectoryInner::OpenId(store) => store.expn(address).await,
|
||||||
}
|
}
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
@@ -136,7 +130,6 @@ impl Directory {
|
|||||||
| DirectoryInner::Imap(_)
|
| DirectoryInner::Imap(_)
|
||||||
| DirectoryInner::Smtp(_)
|
| DirectoryInner::Smtp(_)
|
||||||
| DirectoryInner::Memory(_) => false,
|
| DirectoryInner::Memory(_) => false,
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(_) => true,
|
DirectoryInner::OpenId(_) => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,15 +137,6 @@ impl Directory {
|
|||||||
|
|
||||||
impl DirectoryInner {
|
impl DirectoryInner {
|
||||||
pub fn is_enterprise_directory(&self) -> bool {
|
pub fn is_enterprise_directory(&self) -> bool {
|
||||||
match self {
|
false
|
||||||
DirectoryInner::Internal(_)
|
|
||||||
| DirectoryInner::Ldap(_)
|
|
||||||
| DirectoryInner::Sql(_)
|
|
||||||
| DirectoryInner::Imap(_)
|
|
||||||
| DirectoryInner::Smtp(_)
|
|
||||||
| DirectoryInner::Memory(_) => false,
|
|
||||||
#[cfg(feature = "enterprise")]
|
|
||||||
DirectoryInner::OpenId(_) => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user