Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LDAP filters to include both username and email address #24547

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/doc/administration/command-line.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Admin operations:
- `--synchronize-users`: Enable user synchronization.
- `--page-size value`: Search page size.
- Examples:
- `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`
- `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`
- `update-ldap`: Update existing LDAP (via Bind DN) authentication source
- Options:
- `--id value`: ID of authentication source. Required.
Expand Down
10 changes: 5 additions & 5 deletions docs/content/doc/usage/authentication.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ Adds the following fields:

- User Filter **(required)**
- An LDAP filter declaring how to find the user record that is attempting to
authenticate. The `%s` matching parameter will be substituted with login
authenticate. The `%[1]s` matching parameter will be substituted with login
name given on sign-in form.
- Example: `(&(objectClass=posixAccount)(uid=%s))`
- Example: `(&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))`
- 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)))`
- To substitute more than once, `%[1]s` should be used instead, e.g. when
matching supplied login name against multiple attributes such as user
Expand Down Expand Up @@ -137,11 +137,11 @@ Adds the following fields:
- Example: `ou=Users,dc=mydomain,dc=com`

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

### Verify group membership in LDAP

Expand Down
10 changes: 5 additions & 5 deletions services/auth/source/ldap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ share the following fields:

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

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion templates/admin/auth/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{{end}}
<div class="required field">
<label for="filter">{{.locale.Tr "admin.auths.filter"}}</label>
<input id="filter" name="filter" value="{{$cfg.Filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))" required>
<input id="filter" name="filter" value="{{$cfg.Filter}}" placeholder="e.g. (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))" required>
</div>
<div class="field">
<label for="admin_filter">{{.locale.Tr "admin.auths.admin_filter"}}</label>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/auth/source/ldap.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</div>
<div class="required field">
<label for="filter">{{.locale.Tr "admin.auths.filter"}}</label>
<input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))">
<input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(|(uid=%[1]s)(mail=%[1]s)))">
</div>
<div class="field">
<label for="admin_filter">{{.locale.Tr "admin.auths.admin_filter"}}</label>
Expand Down