Skip to content

Commit 488f534

Browse files
author
Dale McDiarmid
authored
Merge pull request elastic#156 from gingerwizard/master
Support for Role Mapping
2 parents 1c16af1 + a8a0676 commit 488f534

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

tasks/xpack/shield/elasticsearch-shield-file.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,3 @@
6060
template: src=shield/users_roles.j2 dest={{conf_dir}}/shield/users_roles mode=0644 force=yes
6161
when: manage_file_users and users_roles | length > 0
6262

63-
#TODO: Support for mapping file
64-

tasks/xpack/shield/elasticsearch-shield.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
notify: load-native-realms
1515
when: (es_enable_xpack and '"shield" in es_xpack_features') and ((es_users is defined and es_users.native is defined) or (es_roles is defined and es_roles.native is defined))
1616

17-
#---------------------------------------------------------------------
17+
#-----------------------------ROLE MAPPING ----------------------------------------
18+
19+
#Copy Roles files
20+
- name: Copy role_mapping.yml File for Instance
21+
template: src=shield/role_mapping.yml.j2 dest={{conf_dir}}/shield/role_mapping.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
22+
when: es_role_mapping is defined
23+
24+
#------------------------------------------------------------------------------------
1825

1926
#Ensure shield conf directory is created
2027
- name: Ensure shield conf directory exists

templates/shield/role_mapping.yml.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ es_role_mapping | to_nice_yaml }}

test/integration/helpers/serverspec/xpack_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,14 @@
211211
it { should contain 'shield.authc.realms.native1.type: native' }
212212
end
213213

214+
#Test contents of role_mapping.yml
215+
describe file('/etc/elasticsearch/shield_node/shield/role_mapping.yml') do
216+
it { should be_owned_by 'elasticsearch' }
217+
it { should contain 'power_user:' }
218+
it { should contain '- cn=admins,dc=example,dc=com' }
219+
it { should contain 'user:' }
220+
it { should contain '- cn=admins,dc=example,dc=com' }
221+
end
222+
214223
end
215224

test/integration/xpack.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
- watcher
1717
es_api_basic_auth_username: es_admin
1818
es_api_basic_auth_password: changeMe
19+
es_role_mapping:
20+
power_user:
21+
- "cn=admins,dc=example,dc=com"
22+
user:
23+
- "cn=users,dc=example,dc=com"
24+
- "cn=admins,dc=example,dc=com"
1925
es_users:
2026
native:
2127
kibana4_server:

0 commit comments

Comments
 (0)