Skip to content

feat: validate LDAP config at startup#301

Open
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/ldap-config-validation
Open

feat: validate LDAP config at startup#301
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/ldap-config-validation

Conversation

@allamiro

@allamiro allamiro commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #287.

Problem

Unlike OIDC/htpasswd/Filesystem, the LDAP backend had no validate_config(). Empty uri/base_dn/login_attribute or a wrong uri scheme passed startup silently and only failed at login time — where backend errors are shown to users as 'username or password incorrect' (see #260 / #276 for how painful that is to debug).

Changes

  • config::ldap::Ldap::validate(): requires non-empty uri (parseable, scheme ldap/ldaps/ldapi), base_dn, login_attribute
  • LDAP auth backend implements validate_config(), so a misconfigured server now refuses to start with a clear message
  • unit tests for valid and invalid configs

Testing

cargo test: 11/11 pass (2 new) in a rust:1.83 container.


Summary by cubic

Fail-fast LDAP config validation at startup to prevent silent misconfigurations and confusing login errors. Startup now rejects empty or invalid uri, base_dn, or login_attribute with clear messages.

  • New Features
    • Implemented validate_config() in the LDAP backend.
    • Validate uri is parseable and uses ldap/ldaps/ldapi; require non-empty base_dn and login_attribute.
    • Added unit tests for valid and invalid configs.

Written for commit 55a5c62. Summary will update on new commits.

Review in cubic

Empty uri/base_dn/login_attribute and non-ldap(s/i) uri schemes were
accepted silently and only failed at login time, where backend errors
are masked as 'username or password incorrect'. The LDAP backend now
implements validate_config like the other auth backends.
@allamiro allamiro force-pushed the fix/ldap-config-validation branch from 55a5c62 to 6bf53dc Compare June 13, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LDAP config is not validated at startup

1 participant