-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ldap: Add client certificate support (#6668)
* Set up secure ldap server * ldap: Added client cert options Shamelessly copied from https://github.com/andrewshulgin/ldap_search * Added tests for ldap client authentication * Add changelog fragment * Make sure the openssl commands work on older versions of openssl * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> * Remove aliases for new arguments * Add required_together to ldap module declerations --------- Co-authored-by: Felix Fontein <[email protected]>
- Loading branch information
1 parent
bb21693
commit f3ecf4c
Showing
12 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- ldap_* - add new arguments ``client_cert`` and ``client_key`` to the LDAP modules in order to allow certificate authentication (https://github.com/ansible-collections/community.general/pull/6668). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/integration/targets/ldap_search/tasks/tests/auth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# Copyright (c) Ansible Project | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
- debug: | ||
msg: Running tests/auth.yml | ||
|
||
#################################################################### | ||
## Search ########################################################## | ||
#################################################################### | ||
- name: Test simple search for password authenticated user | ||
ldap_search: | ||
dn: "ou=users,dc=example,dc=com" | ||
scope: "onelevel" | ||
filter: "(uid=ldaptest)" | ||
bind_dn: "uid=ldaptest,ou=users,dc=example,dc=com" | ||
bind_pw: "test1pass!" | ||
ignore_errors: true | ||
register: output | ||
|
||
- name: assert that test LDAP user can read its password | ||
assert: | ||
that: | ||
- output is not failed | ||
- output.results | length == 1 | ||
- output.results.0.userPassword is defined | ||
|
||
- name: Test simple search for cert authenticated user | ||
ldap_search: | ||
dn: "ou=users,dc=example,dc=com" | ||
server_uri: "ldap://localhost/" | ||
start_tls: true | ||
ca_path: /usr/local/share/ca-certificates/ca.crt | ||
scope: "onelevel" | ||
filter: "(uid=ldaptest)" | ||
client_cert: "/root/user.crt" | ||
client_key: "/root/user.key" | ||
ignore_errors: true | ||
register: output | ||
|
||
- name: assert that test LDAP user can read its password | ||
assert: | ||
that: | ||
- output is not failed | ||
- output.results | length == 1 | ||
- output.results.0.userPassword is defined |
15 changes: 15 additions & 0 deletions
15
tests/integration/targets/setup_openldap/files/cert_cnconfig.ldif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
dn: cn=config | ||
add: olcTLSCACertificateFile | ||
olcTLSCACertificateFile: /usr/local/share/ca-certificates/ca.crt | ||
- | ||
add: olcTLSCertificateFile | ||
olcTLSCertificateFile: /etc/ldap/localhost.crt | ||
- | ||
add: olcTLSCertificateKeyFile | ||
olcTLSCertificateKeyFile: /etc/ldap/localhost.key | ||
- | ||
add: olcAuthzRegexp | ||
olcAuthzRegexp: {0}"UID=([^,]*)" uid=$1,ou=users,dc=example,dc=com | ||
- | ||
add: olcTLSVerifyClient | ||
olcTLSVerifyClient: allow |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/setup_openldap/files/cert_cnconfig.ldif.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
SPDX-FileCopyrightText: Ansible Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ homeDirectory: /home/ldaptest | |
cn: LDAP Test | ||
gecos: LDAP Test | ||
displayName: LDAP Test | ||
userPassword: test1pass! | ||
mail: [email protected] | ||
sn: Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters