Some checks failed
CI / Rustfmt (push) Failing after 21s
CI / Cargo Audit & Deny (push) Failing after 33s
CI / Web Blocking Checks (push) Successful in 50s
CI / Security Blocking Checks (push) Successful in 7s
CI / Web Advisory Checks (push) Successful in 33s
CI / Security Advisory Checks (push) Successful in 34s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 1s
Publish Images And Chart / Publish init-packs (push) Failing after 11s
Publish Images And Chart / Publish init-user (push) Failing after 10s
Publish Images And Chart / Publish migrations (push) Failing after 11s
Publish Images And Chart / Publish sensor (push) Failing after 10s
Publish Images And Chart / Publish web (push) Failing after 10s
Publish Images And Chart / Publish worker (push) Failing after 10s
Publish Images And Chart / Publish api (push) Failing after 7s
Publish Images And Chart / Publish executor (push) Failing after 9s
Publish Images And Chart / Publish notifier (push) Failing after 10s
Publish Images And Chart / Publish Helm Chart (push) Has been skipped
CI / Clippy (push) Successful in 18m52s
CI / Tests (push) Has been cancelled
3.7 KiB
3.7 KiB
LDAP Authentication Support
Date: 2026-03-19
Summary
Added LDAP as an authentication provider alongside the existing OIDC and local username/password login methods. LDAP authentication follows the same architectural patterns as OIDC — server-side credential verification, identity upsert with provider-specific claims stored in the attributes JSONB column, and JWT token issuance.
Changes
Backend (Rust)
New Files
crates/api/src/auth/ldap.rs— LDAP authentication module using theldap3crate (v0.12). Supports two authentication modes:- Direct bind: Constructs a DN from a configurable
bind_dn_template(e.g.,uid={login},ou=users,dc=example,dc=com) and binds directly as the user. - Search-and-bind: Binds as a service account (or anonymous), searches for the user entry using
user_search_base+user_filter, then re-binds as the discovered DN with the user's password. - After successful authentication, fetches user attributes (login, email, display name, groups) and upserts an identity row with claims stored under
attributes.ldap.
- Direct bind: Constructs a DN from a configurable
Modified Files
-
crates/common/src/config.rs:- Added
LdapConfigstruct with fields for server URL, bind DN template, search base/filter, service account credentials, attribute mapping, TLS settings, and UI metadata (provider name/label/icon). - Added
ldap: Option<LdapConfig>toSecurityConfig. - Added
show_ldap_login: booltoLoginPageConfig.
- Added
-
crates/common/src/repositories/identity.rs:- Added
find_by_ldap_dn()method toIdentityRepository, queryingattributes->'ldap'->>'server_url'andattributes->'ldap'->>'dn'(mirrors the existingfind_by_oidc_subjectpattern).
- Added
-
crates/api/Cargo.toml:- Added
ldap3 = "0.12"dependency.
- Added
-
crates/api/src/auth/mod.rs:- Added
pub mod ldap;.
- Added
-
crates/api/src/routes/auth.rs:- Added
POST /auth/ldap/loginroute andldap_loginhandler (validatesLdapLoginRequest, delegates toldap::authenticate, returnsTokenResponse). - Updated
auth_settingshandler to populate LDAP fields in the response.
- Added
-
crates/api/src/dto/auth.rs:- Added
ldap_enabled,ldap_visible_by_default,ldap_provider_name,ldap_provider_label,ldap_provider_icon_urlfields toAuthSettingsResponse.
- Added
Frontend (React/TypeScript)
web/src/pages/auth/LoginPage.tsx:- Extended
AuthSettingsResponseinterface with LDAP fields. - Added LDAP login form (username/password) with emerald-colored submit button, error handling, and
?auth=ldapoverride support. - Added divider between sections when multiple login methods are visible.
- Extended
Configuration
config.example.yaml: Added full LDAP configuration example with comments explaining direct-bind vs search-and-bind modes.config.development.yaml: Added disabled LDAP section with direct-bind template.
Documentation
AGENTS.md: Updated Authentication & Security section to document both OIDC and LDAP providers, their config keys, routes, identity matching, and login page configuration.
Architecture Notes
- LDAP authentication is a synchronous POST flow (no browser redirects), unlike OIDC which uses authorization code redirects. The user submits credentials to
POST /auth/ldap/loginand receives JWT tokens directly. - Identity deduplication uses
server_url + dnas the composite key (stored inattributes.ldap), analogous to OIDC'sissuer + sub. - Login name collision avoidance uses the same SHA-256 fallback pattern as OIDC (
ldap:<24-hex-chars>). - The
ldap3crate connection is driven asynchronously on the Tokio runtime vialdap3::drive!(conn). - STARTTLS and TLS certificate verification skip are configurable per-deployment.