Open source third party OIDC support

This commit is contained in:
mdecimus 2025-01-31 09:25:03 +01:00
parent 54733de0ff
commit cac9152d27
6 changed files with 8 additions and 42 deletions

View file

@ -8,7 +8,6 @@ pub mod imap;
pub mod internal;
pub mod ldap;
pub mod memory;
#[cfg(feature = "enterprise")]
pub mod oidc;
pub mod smtp;
pub mod sql;

View file

@ -1,11 +1,7 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
*
* SPDX-License-Identifier: LicenseRef-SEL
*
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
* is NOT open source software.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use std::time::Duration;

View file

@ -1,11 +1,7 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
*
* SPDX-License-Identifier: LicenseRef-SEL
*
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
* is NOT open source software.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use ahash::HashMap;

View file

@ -1,11 +1,7 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <hello@stalw.art>
*
* SPDX-License-Identifier: LicenseRef-SEL
*
* This file is subject to the Stalwart Enterprise License Agreement (SEL) and
* is NOT open source software.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
pub mod config;

View file

@ -16,8 +16,8 @@ use ahash::AHashMap;
use crate::{
backend::{
imap::ImapDirectory, ldap::LdapDirectory, memory::MemoryDirectory, smtp::SmtpDirectory,
sql::SqlDirectory,
imap::ImapDirectory, ldap::LdapDirectory, memory::MemoryDirectory, oidc::OpenIdDirectory,
smtp::SmtpDirectory, sql::SqlDirectory,
},
Directories, Directory, DirectoryInner,
};
@ -84,13 +84,8 @@ impl Directories {
"memory" => MemoryDirectory::from_config(config, prefix, data_store.clone())
.await
.map(DirectoryInner::Memory),
#[cfg(feature = "enterprise")]
"oidc" => crate::backend::oidc::OpenIdDirectory::from_config(
config,
prefix,
data_store.clone(),
)
.map(DirectoryInner::OpenId),
"oidc" => OpenIdDirectory::from_config(config, prefix, data_store.clone())
.map(DirectoryInner::OpenId),
unknown => {
let err = format!("Unknown directory type: {unknown:?}");
config.new_parse_error(("directory", id, "type"), err);

View file

@ -24,7 +24,6 @@ impl Directory {
DirectoryInner::Imap(store) => store.query(by).await,
DirectoryInner::Smtp(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,
}
.caused_by(trc::location!())
@ -38,7 +37,6 @@ impl Directory {
DirectoryInner::Imap(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,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(store) => store.email_to_id(address).await,
}
.caused_by(trc::location!())
@ -59,7 +57,6 @@ impl Directory {
DirectoryInner::Imap(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,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(store) => store.is_local_domain(domain).await,
}
.caused_by(trc::location!())?;
@ -87,7 +84,6 @@ impl Directory {
DirectoryInner::Imap(store) => store.rcpt(email).await,
DirectoryInner::Smtp(store) => store.rcpt(email).await,
DirectoryInner::Memory(store) => store.rcpt(email).await,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(store) => store.rcpt(email).await,
}
.caused_by(trc::location!())?;
@ -108,7 +104,6 @@ impl Directory {
DirectoryInner::Imap(store) => store.vrfy(address).await,
DirectoryInner::Smtp(store) => store.vrfy(address).await,
DirectoryInner::Memory(store) => store.vrfy(address).await,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(store) => store.vrfy(address).await,
}
.caused_by(trc::location!())
@ -122,7 +117,6 @@ impl Directory {
DirectoryInner::Imap(store) => store.expn(address).await,
DirectoryInner::Smtp(store) => store.expn(address).await,
DirectoryInner::Memory(store) => store.expn(address).await,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(store) => store.expn(address).await,
}
.caused_by(trc::location!())
@ -136,7 +130,6 @@ impl Directory {
| DirectoryInner::Imap(_)
| DirectoryInner::Smtp(_)
| DirectoryInner::Memory(_) => false,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(_) => true,
}
}
@ -144,15 +137,6 @@ impl Directory {
impl DirectoryInner {
pub fn is_enterprise_directory(&self) -> bool {
match self {
DirectoryInner::Internal(_)
| DirectoryInner::Ldap(_)
| DirectoryInner::Sql(_)
| DirectoryInner::Imap(_)
| DirectoryInner::Smtp(_)
| DirectoryInner::Memory(_) => false,
#[cfg(feature = "enterprise")]
DirectoryInner::OpenId(_) => true,
}
false
}
}