Skip to content

Comments

block adding users over license limits in openid and ldap#2104

Open
filipslezaklab wants to merge 7 commits intodevfrom
block-sync
Open

block adding users over license limits in openid and ldap#2104
filipslezaklab wants to merge 7 commits intodevfrom
block-sync

Conversation

@filipslezaklab
Copy link
Contributor

@filipslezaklab filipslezaklab commented Feb 20, 2026

openid limits tests

block adding excess users via openid sync and login

send simple (placeholder) emails notifying active admins of the blocking.

Related #2004

openid limits tests

block adding excess users via openid sync and login
@filipslezaklab filipslezaklab self-assigned this Feb 20, 2026
@filipslezaklab filipslezaklab added the ignore-for-release Don't list PR in release notes label Feb 20, 2026
let pool = setup_pool(options).await;

let config = DefGuardConfig::new_test_config();
let _ = SERVER_CONFIG.set(config.clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably clone() is not needed.


if let Some((user_count, limit)) = reached_user_license_limit() {
error!(
"Skipping OpenID account creation for user {} (email: {}) because \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Embed variables in formatting string.

if let Some(limit) = user_limit.filter(|limit| user_count >= *limit) {
error!(
"Skipping LDAP import of user {} (email: {}) because license user limit \
has been reached ({}/{})",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
has been reached ({}/{})",
has been reached ({user_count}/{limit})",

if let Some((user_count, limit)) = reached_user_license_limit() {
error!(
"Skipping LDAP account creation for user {} (email: {}) because license user \
limit has been reached ({}/{})",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
limit has been reached ({}/{})",
limit has been reached ({user_count}/{limit})",

pub async fn get_admins_emails(pool: &PgPool) -> Result<Vec<String>, sqlx::Error> {
debug!("Getting emails of active admins");
query_scalar::<_, String>(
"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SELECT u.email FROM "user" u JOIN group_user gu ON gu.user_id = u.id JOIN "group" g ON gu.group_id = g.id WHERE g.is_admin;

@@ -0,0 +1,3 @@
INSERT INTO mail_context (template, section, language_tag, text) VALUES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename migration to [2.0.0]…

@@ -0,0 +1 @@
v25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release Don't list PR in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants