[PR #12835] [MERGED] Fix: Robust Handling of LDAP Email Attribute Types #9827

Closed
opened 2025-11-11 18:32:45 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/12835
Author: @weisser-dev
Created: 4/14/2025
Status: Merged
Merged: 4/14/2025
Merged by: @tjbck

Base: devHead: dev


📝 Commits (1)

📊 Changes

1 file changed (+2 additions, -0 deletions)

View changed files

📝 backend/open_webui/routers/auths.py (+2 -0)

📄 Description

Previously, the code only handled str and list types for the LDAP email attribute. This caused login failures when the attribute was returned as a different type (e.g., a custom LDAP object).

Old code fails with:

email = entry["mail"]
# email = Attribute("mail", ["user@example.com"]) → not str or list
email.lower()  # ❌ Attribute has no .lower()

New code fixes this:

email = entry["mail"].value
if not email:
    raise HTTPException(...)
elif isinstance(email, str):
    email = email.lower()
elif isinstance(email, list):
    email = email[0].lower()
else:
    email = str(email).lower()  # ✅ Fallback for unknown types

This makes login more robust across different LDAP setups and prevents edge case failures.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/12835 **Author:** [@weisser-dev](https://github.com/weisser-dev) **Created:** 4/14/2025 **Status:** ✅ Merged **Merged:** 4/14/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (1) - [`c749083`](https://github.com/open-webui/open-webui/commit/c7490839352e3f6e605462f79cbac3c09673b56a) Update auths.py ### 📊 Changes **1 file changed** (+2 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/auths.py` (+2 -0) </details> ### 📄 Description Previously, the code only handled str and list types for the LDAP email attribute. This caused login failures when the attribute was returned as a different type (e.g., a custom LDAP object). Old code fails with: ``` email = entry["mail"] # email = Attribute("mail", ["user@example.com"]) → not str or list email.lower() # ❌ Attribute has no .lower() ``` New code fixes this: ``` email = entry["mail"].value if not email: raise HTTPException(...) elif isinstance(email, str): email = email.lower() elif isinstance(email, list): email = email[0].lower() else: email = str(email).lower() # ✅ Fallback for unknown types ``` This makes login more robust across different LDAP setups and prevents edge case failures. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 18:32:45 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#9827