This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new 1434564  Add a GitHub username query for admins to LDAP
1434564 is described below

commit 14345645c51e4c8c19b99586aeb4f7c3856baa29
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Aug 15 14:39:44 2025 +0100

    Add a GitHub username query for admins to LDAP
---
 atr/blueprints/admin/admin.py |  6 +++---
 atr/ldap.py                   | 12 ++++++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/atr/blueprints/admin/admin.py b/atr/blueprints/admin/admin.py
index cda0249..e766517 100644
--- a/atr/blueprints/admin/admin.py
+++ b/atr/blueprints/admin/admin.py
@@ -83,8 +83,8 @@ class DeleteReleaseForm(forms.Typed):
 
 
 class LdapLookupForm(forms.Typed):
-    uid = forms.string("ASF UID (optional)", placeholder="Enter ASF UID, e.g. 
johnsmith, or * for all")
-    email = forms.string("Email address (optional)", placeholder="Enter email 
address, e.g. [email protected]")
+    uid = forms.optional("ASF UID (optional)", placeholder="Enter ASF UID, 
e.g. johnsmith, or * for all")
+    email = forms.optional("Email address (optional)", placeholder="Enter 
email address, e.g. [email protected]")
     submit = forms.submit("Lookup")
 
 
@@ -493,7 +493,7 @@ async def admin_ldap() -> str:
             email_query=email_query,
             bind_dn_from_config=bind_dn,
             bind_password_from_config=bind_password,
-            email_only=True,
+            email_only=False,
         )
         await asyncio.to_thread(ldap.search, ldap_params)
         end = time.perf_counter_ns()
diff --git a/atr/ldap.py b/atr/ldap.py
index 1a16ee9..b3661d6 100644
--- a/atr/ldap.py
+++ b/atr/ldap.py
@@ -56,7 +56,7 @@ class Search:
         ldap_attrs: list[str] | None = None,
     ) -> list[dict[str, Any]]:
         if not self._conn:
-            raise RuntimeError("Connection not available.")
+            raise RuntimeError("LDAP connection not available")
 
         attributes = ldap_attrs if ldap_attrs else ldap3.ALL_ATTRIBUTES
         self._conn.search(
@@ -78,6 +78,7 @@ class Search:
 class SearchParameters:
     uid_query: str | None = None
     email_query: str | None = None
+    github_username_query: str | None = None
     bind_dn_from_config: str | None = None
     bind_password_from_config: str | None = None
     results_list: list[dict[str, str | list[str]]] = 
dataclasses.field(default_factory=list)
@@ -146,10 +147,17 @@ def _search_core(params: SearchParameters) -> None:
         else:
             filters.append(f"(asf-altEmail={escaped_email})")
 
+    if params.github_username_query:
+        
filters.append(f"(githubUsername={conv.escape_filter_chars(params.github_username_query)})")
+
     if not filters:
-        params.err_msg = "Please provide a UID or an email address to search."
+        params.err_msg = "Please provide a UID, an email address, or a GitHub 
username to search."
         return
 
+    _search_core_2(params, filters)
+
+
+def _search_core_2(params: SearchParameters, filters: list[str]) -> None:
     search_filter = f"(&{''.join(filters)})" if (len(filters) > 1) else 
filters[0]
 
     if not params.connection:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to