Skip to content

Commit

Permalink
v0.10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Nov 7, 2024
1 parent 45ad45f commit afef155
Show file tree
Hide file tree
Showing 21 changed files with 283 additions and 115 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [0.10.6] - 2024-11-07

To upgrade replace the `stalwart-mail` binary and then upgrade to the latest web-admin.

### Added
- Enterprise license automatic renewals before expiration (disabled by default).
- Allow to LDAP search using bind dn instead of auth bind connection when bind auth is enabled (#873)

### Changed

### Fixed
- Include `preferred_username` and `email` in OIDC `id_token`.
- Verify roles and permissions when creating or modifying accounts (#874)

## [0.10.5] - 2024-10-15

To upgrade replace the `stalwart-mail` binary.
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. <[email protected]>"]
license = "AGPL-3.0-only OR LicenseRef-SEL"
repository = "https://github.com/stalwartlabs/cli"
homepage = "https://github.com/stalwartlabs/cli"
version = "0.10.5"
version = "0.10.6"
edition = "2021"
readme = "README.md"
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "common"
version = "0.10.5"
version = "0.10.6"
edition = "2021"
resolver = "2"

Expand Down
3 changes: 2 additions & 1 deletion crates/common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ impl Core {
// SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]>
// SPDX-License-Identifier: LicenseRef-SEL
#[cfg(feature = "enterprise")]
let enterprise = crate::enterprise::Enterprise::parse(config, &stores, &data).await;
let enterprise =
crate::enterprise::Enterprise::parse(config, &config_manager, &stores, &data).await;

#[cfg(feature = "enterprise")]
let is_enterprise = enterprise.is_some();
Expand Down
83 changes: 73 additions & 10 deletions crates/common/src/enterprise/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,93 @@ use trc::{EventType, MetricType, TOTAL_EVENT_COUNT};
use utils::config::{
cron::SimpleCron,
utils::{AsKey, ParseValue},
Config,
Config, ConfigKey,
};

use crate::expr::{tokenizer::TokenMap, Expression};
use crate::{
expr::{tokenizer::TokenMap, Expression},
manager::config::ConfigManager,
};

use super::{
license::LicenseValidator, llm::AiApiConfig, AlertContent, AlertContentToken, AlertMethod,
license::LicenseKey, llm::AiApiConfig, AlertContent, AlertContentToken, AlertMethod,
Enterprise, MetricAlert, MetricStore, TraceStore, Undelete,
};

impl Enterprise {
pub async fn parse(config: &mut Config, stores: &Stores, data: &Store) -> Option<Self> {
let license = match LicenseValidator::new()
.try_parse(config.value("enterprise.license-key")?)
.and_then(|key| {
key.into_validated_key(config.value("lookup.default.hostname").unwrap_or_default())
}) {
Ok(key) => key,
pub async fn parse(
config: &mut Config,
config_manager: &ConfigManager,
stores: &Stores,
data: &Store,
) -> Option<Self> {
let server_hostname = config.value("lookup.default.hostname")?;
let mut update_license = None;

let license_result = match (
config.value("enterprise.license-key"),
config.value("enterprise.api-key"),
) {
(Some(license_key), maybe_api_key) => {
match (LicenseKey::new(license_key, server_hostname), maybe_api_key) {
(Ok(license), Some(api_key)) if license.is_near_expiration() => Ok(license
.try_renew(api_key)
.await
.map(|result| {
update_license = Some(result.encoded_key);
result.key
})
.unwrap_or(license)),
(Ok(license), None) => Ok(license),
(Err(_), Some(api_key)) => LicenseKey::invalid(server_hostname)
.try_renew(api_key)
.await
.map(|result| {
update_license = Some(result.encoded_key);
result.key
}),
(maybe_license, _) => maybe_license,
}
}
(None, Some(api_key)) => LicenseKey::invalid(server_hostname)
.try_renew(api_key)
.await
.map(|result| {
update_license = Some(result.encoded_key);
result.key
}),
(None, None) => {
return None;
}
};

// Report error
let license = match license_result {
Ok(license) => license,
Err(err) => {
config.new_build_warning("enterprise.license-key", err.to_string());
return None;
}
};

// Update the license if a new one was obtained
if let Some(license) = update_license {
config
.keys
.insert("enterprise.license-key".to_string(), license.clone());
if let Err(err) = config_manager
.set([ConfigKey {
key: "enterprise.license-key".to_string(),
value: license.to_string(),
}])
.await
{
trc::error!(err
.caused_by(trc::location!())
.details("Failed to update license key"));
}
}

match data
.count_principals(None, Type::Individual.into(), None)
.await
Expand Down
Loading

0 comments on commit afef155

Please sign in to comment.