mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #20159] [CLOSED] fix(ldap): enable placeholder substitution in LDAP search filters #25484
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20159
Author: @polaz
Created: 12/24/2025
Status: ❌ Closed
Base:
main← Head:fix/ldap-search-filter-placeholder📝 Commits (1)
9192b34fix(ldap): enable placeholder substitution in LDAP search filters📊 Changes
1 file changed (+13 additions, -1 deletions)
View changed files
📝
backend/open_webui/routers/auths.py(+13 -1)📄 Description
Summary
This PR fixes the LDAP search filter placeholder substitution issue discussed in #16760.
The LDAP search filter configuration now properly supports placeholder variables that get substituted with the actual username during authentication:
%s- replaced with the escaped username%(user)s- replaced with the escaped usernameProblem
Previously, if a user configured the LDAP search filter to use placeholders like
(uid=%s), these placeholders were never substituted with the actual username. The filter was concatenated as-is, resulting in malformed LDAP queries and "User not found" errors.Solution
Added placeholder substitution logic before constructing the LDAP search filter:
escape_filter_chars()(already done but now reused)%(user)splaceholders with the escaped username%splaceholders with the escaped usernameExamples
Now users can create complex LDAP filters like:
(uid=%s)- simple user lookup(&(objectClass=person)(memberOf=cn=allowed-users,ou=groups,dc=example,dc=com)(uid=%s))- lookup with group membership restrictionSecurity
The username is properly escaped using
escape_filter_chars()before substitution to prevent LDAP injection attacks.Testing
%splaceholder%(user)splaceholderFixes #16760
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.