Skip to content

Commit b8c19e7

Browse files
authored
Update LDAP filters to include both username and email address (#24547)
Since the login form label for user_name unconditionally displays `Username or Email Address` for the `user_name` field, bring matching LDAP filters to more prominence in the documentation/placeholders. Signed-off-by: Gary Moon <gary@garymoon.net>
1 parent 09dd4b4 commit b8c19e7

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

docs/content/doc/administration/command-line.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Admin operations:
225225
- `--synchronize-users`: Enable user synchronization.
226226
- `--page-size value`: Search page size.
227227
- Examples:
228-
- `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(uid=%s))" --email-attribute mail`
228+
- `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" --email-attribute mail`
229229
- `update-ldap`: Update existing LDAP (via Bind DN) authentication source
230230
- Options:
231231
- `--id value`: ID of authentication source. Required.

docs/content/doc/usage/authentication.en-us.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ Adds the following fields:
100100

101101
- User Filter **(required)**
102102
- An LDAP filter declaring how to find the user record that is attempting to
103-
authenticate. The `%s` matching parameter will be substituted with login
103+
authenticate. The `%[1]s` matching parameter will be substituted with login
104104
name given on sign-in form.
105-
- Example: `(&(objectClass=posixAccount)(uid=%s))`
105+
- Example: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))`
106106
- Example for Microsoft Active Directory (AD): `(&(objectCategory=Person)(memberOf=CN=user-group,OU=example,DC=example,DC=org)(sAMAccountName=%s)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))`
107107
- To substitute more than once, `%[1]s` should be used instead, e.g. when
108108
matching supplied login name against multiple attributes such as user
@@ -137,11 +137,11 @@ Adds the following fields:
137137
- Example: `ou=Users,dc=mydomain,dc=com`
138138

139139
- User Filter **(required)**
140-
- An LDAP filter declaring when a user should be allowed to log in. The `%s`
140+
- An LDAP filter declaring when a user should be allowed to log in. The `%[1]s`
141141
matching parameter will be substituted with login name given on sign-in
142142
form.
143-
- Example: `(&(objectClass=posixAccount)(cn=%s))`
144-
- Example: `(&(objectClass=posixAccount)(uid=%s))`
143+
- Example: `(&(objectClass=posixAccount)(|(cn=%[1]s)(mail=%[1]s)))`
144+
- Example: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))`
145145

146146
### Verify group membership in LDAP
147147

services/auth/source/ldap/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ share the following fields:
8181

8282
* User Filter **(required)**
8383
* An LDAP filter declaring how to find the user record that is attempting to
84-
authenticate. The '%s' matching parameter will be substituted with the
84+
authenticate. The '%[1]s' matching parameter will be substituted with the
8585
user's username.
86-
* Example: (&(objectClass=posixAccount)(uid=%s))
86+
* Example: (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))
8787

8888
**LDAP using simple auth** adds the following fields:
8989

@@ -98,10 +98,10 @@ share the following fields:
9898
* Example: ou=Users,dc=mydomain,dc=com
9999

100100
* User Filter **(required)**
101-
* An LDAP filter declaring when a user should be allowed to log in. The `%s`
101+
* An LDAP filter declaring when a user should be allowed to log in. The `%[1]s`
102102
matching parameter will be substituted with the user's username.
103-
* Example: (&(objectClass=posixAccount)(cn=%s))
104-
* Example: (&(objectClass=posixAccount)(uid=%s))
103+
* Example: (&(objectClass=posixAccount)(|(cn=%[1]s)(mail=%[1]s)))
104+
* Example: (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))
105105

106106
**Verify group membership in LDAP** uses the following fields:
107107

templates/admin/auth/edit.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
{{end}}
7171
<div class="required field">
7272
<label for="filter">{{.locale.Tr "admin.auths.filter"}}</label>
73-
<input id="filter" name="filter" value="{{$cfg.Filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))" required>
73+
<input id="filter" name="filter" value="{{$cfg.Filter}}" placeholder="e.g. (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" required>
7474
</div>
7575
<div class="field">
7676
<label for="admin_filter">{{.locale.Tr "admin.auths.admin_filter"}}</label>

templates/admin/auth/source/ldap.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</div>
4545
<div class="required field">
4646
<label for="filter">{{.locale.Tr "admin.auths.filter"}}</label>
47-
<input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))">
47+
<input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))">
4848
</div>
4949
<div class="field">
5050
<label for="admin_filter">{{.locale.Tr "admin.auths.admin_filter"}}</label>

0 commit comments

Comments
 (0)