Skip to content

Commit 661ba30

Browse files
test: Test authorization via LDAP (#45)
1 parent 7b60bd0 commit 661ba30

File tree

4 files changed

+74
-123
lines changed

4 files changed

+74
-123
lines changed

tests/templates/kuttl/ldap/10-install-openldap.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,42 @@ spec:
1818
spec:
1919
containers:
2020
- name: openldap
21-
image: bitnamilegacy/openldap:2.5
21+
image: bitnamilegacy/openldap:2.6
2222
env:
23+
# LDAP baseDN of the LDAP tree
24+
- name: LDAP_ROOT
25+
value: dc=stackable,dc=tech
26+
# LDAP database admin user
2327
- name: LDAP_ADMIN_USERNAME
2428
value: admin
29+
# LDAP database admin password
2530
- name: LDAP_ADMIN_PASSWORD
2631
value: admin
32+
# Comma separated list of LDAP users to create in the default LDAP tree
33+
- name: LDAP_USERS
34+
value: integrationtest
35+
# Comma separated list of passwords to use for LDAP users
36+
- name: LDAP_PASSWORDS
37+
value: integrationtest
38+
# Name for the user's organizational unit
39+
- name: LDAP_USER_OU
40+
value: users
41+
# Name for the group's organizational unit
42+
- name: LDAP_GROUP_OU
43+
value: groups
44+
# Group used to group created users
45+
- name: LDAP_GROUP
46+
value: testgroup
47+
# Whether to enable TLS for traffic or not
2748
- name: LDAP_ENABLE_TLS
2849
value: "yes"
50+
# File containing the certificate file for the TLS traffic
2951
- name: LDAP_TLS_CERT_FILE
3052
value: /tls/tls.crt
53+
# File containing the key for certificate
3154
- name: LDAP_TLS_KEY_FILE
3255
value: /tls/tls.key
56+
# File containing the CA of the certificate
3357
- name: LDAP_TLS_CA_FILE
3458
value: /tls/ca.crt
3559
ports:

tests/templates/kuttl/ldap/11-assert.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/templates/kuttl/ldap/11-create-ldap-user.yaml

Lines changed: 0 additions & 107 deletions
This file was deleted.

tests/templates/kuttl/ldap/20_opensearch-security-config.yaml.j2

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ stringData:
3434
config:
3535
dynamic:
3636
authc:
37+
# Allow internal authentication for debugging purposes, so that OpenSearch Dashboards can
38+
# be used which uses the internal user kibanaserver.
39+
internal_auth:
40+
order: 0
41+
http_enabled: true
42+
transport_enabled: true
43+
http_authenticator:
44+
type: basic
45+
challenge: false
46+
authentication_backend:
47+
type: internal
3748
ldap:
3849
http_enabled: true
3950
transport_enabled: true
@@ -48,11 +59,28 @@ stringData:
4859
hosts:
4960
- openldap.$NAMESPACE.svc.cluster.local:1636
5061
pemtrustedcas_filepath: {{ test_scenario['values']['opensearch_home'] }}/config/tls/ca.crt
51-
userbase: ou=users,dc=example,dc=org
62+
userbase: ou=users,dc=stackable,dc=tech
63+
username_attribute: uid
64+
usersearch: (cn={0})
65+
verify_hostnames: true
66+
authz:
67+
ldap:
68+
http_enabled: true
69+
transport_enabled: true
70+
authorization_backend:
71+
type: ldap
72+
config:
73+
enable_ssl: true
74+
hosts:
75+
- openldap.$NAMESPACE.svc.cluster.local:1636
76+
pemtrustedcas_filepath: {{ test_scenario['values']['opensearch_home'] }}/config/tls/ca.crt
77+
userbase: ou=users,dc=stackable,dc=tech
5278
username_attribute: uid
5379
usersearch: (cn={0})
5480
verify_hostnames: true
55-
authz: {}
81+
rolesearch: (member={0})
82+
rolebase: ou=groups,dc=stackable,dc=tech
83+
rolename: cn
5684
internal_users.yml: |
5785
---
5886
# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh
@@ -82,6 +110,20 @@ stringData:
82110
_meta:
83111
type: roles
84112
config_version: 2
113+
114+
test-role:
115+
reserved: false
116+
cluster_permissions:
117+
- indices:data/write/bulk*
118+
index_permissions:
119+
- index_patterns:
120+
- "*"
121+
allowed_actions:
122+
- indices:admin/create
123+
- indices:admin/delete
124+
- indices:admin/mapping/put
125+
- indices:data/write/bulk*
126+
- indices:data/write/index
85127
roles_mapping.yml: |
86128
---
87129
_meta:
@@ -92,13 +134,16 @@ stringData:
92134
reserved: false
93135
backend_roles:
94136
- admin
95-
users:
96-
- integrationtest
97137

98138
kibana_server:
99139
reserved: true
100140
users:
101141
- kibanaserver
142+
143+
test-role:
144+
reserved: false
145+
backend_roles:
146+
- testgroup
102147
tenants.yml: |
103148
---
104149
_meta:

0 commit comments

Comments
 (0)