I have configured X-Pack with LDAP in my ES Cluster. I am able to create the roles and role mappings using APIs. But role mapping is not taking effect in ES Cluster.
It is working only If I update the role_mapping,yml file.
create role mapping command
curl -X POST "localhost:9200/_xpack/security/role_mapping/ES_Readonly_mapping" -H 'Content-Type: application/json' -d' '{"roles":["ES_Readonly"],"enabled":true,"rules":{"field":{"dn":"cn=user1,ou=Production,ou=Users,ou=Accounts,dc=my,dc=t-example,dc=com"}}}'
The snippets above show that you have created a Role Mapping that would give the role ES_Readonly to the user with the DN : cn=user1,ou=Production,ou=Users,ou=Accounts,dc=my,dc=example,dc=com
You don't share any information on how you attempt to verify if this works or not, and what is the behavior you are seeing that makes you think it's not working. Please
Make sure that the DN of the user you attempt to login as, is indeed cn=user1,ou=Production,ou=Users,ou=Accounts,dc=my,dc=example,dc=com
The response will contain the roles that have been mapped to this user. The logs will also contain information on the role mapping that was attempted and indications of what can be going wrong.
Which version are you using? The role mapping API was case sensitive and whitespace sensitive until 6.2 . So you would have to update your mapping as following:
curl -X POST "localhost:9200/_xpack/security/role_mapping/ES_Readonly_mapping" -H 'Content-Type: application/json' -d' '{"roles":["ES_Readonly"],"enabled":true,"rules":{"field":{"dn":"CN=user1,OU=Production,OU=Users,OU=Accounts,DC=my,DC=example,DC=com"}}}'
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.