# management api user/ rolesmapping

**URL:** <https://forum.search-guard.com/t/management-api-user-rolesmapping/407>\
**Category:** Search Guard\
**Created:** [March 7, 2017, 9:44am UTC](https://forum.search-guard.com/t/management-api-user-rolesmapping/407 "2017-03-07T09:44:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Me\_He](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Me\_He](https://forum.search-guard.com/u/Me_He)\
**Post date:** [March 7, 2017, 9:44am UTC](https://forum.search-guard.com/t/management-api-user-rolesmapping/407/1 "2017-03-07T09:44:15Z")

</div>

Hi,

I am evaluating search guard on my local machine with bundle elasticsearch-5.1.1-10-8BCFA2D1-34F6-4A0F-BEA8-9F3ACA113B38.

when accessing:  
[https://localhost:9200/\_searchguard/api/user/worf](https://localhost:9200/_searchguard/api/user/worf) I get

{“worf” : {“hash” : “$2a$12$A41IxPXV1/Dx46C6i1ufGubv.p3qYX7xVcY46q33sylYbIqQVwTMu” }}

and with [https://localhost:9200/\_searchguard/api/rolesmapping/sg\_role\_starfleet](https://localhost:9200/_searchguard/api/rolesmapping/sg_role_starfleet)":

{ “sg\_role\_starfleet” : {“backendroles” : [“starfleet”,“captains”,“defectors”,“cn=ldaprole,ou=groups,dc=example,dc=com”],“hosts” : [“\*.starfleetintranet.com”],“users” : [“worf”]}}

The first api call show no roles for user worf, while the second claims he has sg\_role\_starfleet , is that a bug or by intention, or is it possible that I have somehow misconfigured my system.

We are not yet sure which approach for rights management to choose.  
We want to avoid building a frontend for user and rights management and chose something where changes can be managed by other tools.  
One idea would be to use ldap. Is it possible to access the roles of a given user via searchguard management api when using ldap backend for authorization?

The alternative idea is to handle everything with client certificates. If we do that, is it enough to define which field shall be used as user name or must this user name then be configured in the internal user database? Same question for roles and rights. We would want to map the Organizational Unit Name to a role to avoid reconfiguring of searchguard for each change in userbase. Is that possible?  
This leads to the next question: must one restart searchguard/elasticsearch when replacing/changing truststore.jks?

best,  
Meike

---

<div class="post-metadata">

**Author:** ![searchguard\_google\_group](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.search-guard.com/searchguard_google_group/32/462_2.png) [@searchguard\_google\_group](https://forum.search-guard.com/u/searchguard_google_group)\
**Post date:** [March 9, 2017, 3:53pm UTC](https://forum.search-guard.com/t/management-api-user-rolesmapping/407/2 "2017-03-09T15:53:20Z")

</div>

please share your sg\_\*.yml config files

> Hi,
> 
> I am evaluating search guard on my local machine with bundle elasticsearch-5.1.1-10-8BCFA2D1-34F6-4A0F-BEA8-9F3ACA113B38.
> 
> when accessing:  
> [https://localhost:9200/\_searchguard/api/user/worf](https://localhost:9200/_searchguard/api/user/worf) I get
> 
> {"worf" : {"hash" : "$2a$12$A41IxPXV1/Dx46C6i1ufGubv.p3qYX7xVcY46q33sylYbIqQVwTMu" }}
> 
> and with [https://localhost:9200/\_searchguard/api/rolesmapping/sg\_role\_starfleet&quot;:](https://localhost:9200/_searchguard/api/rolesmapping/sg_role_starfleet&quot;:)
> 
> { "sg\_role\_starfleet" : {"backendroles" : ["starfleet","captains","defectors","cn=ldaprole,ou=groups,dc=example,dc=com"],"hosts" : ["\*.starfleetintranet.com"],"users" : ["worf"]}}
> 
> The first api call show no roles for user worf, while the second claims he has sg\_role\_starfleet , is that a bug or by intention, or is it possible that I have somehow misconfigured my system.

Regarding the roles: There is a difference between a "backend role" (roles assigned to users by the authz backend) and a search guard role (sg role) which are defined in roles\_mapping.yml

> We are not yet sure which approach for rights management to choose.  
> We want to avoid building a frontend for user and rights management and chose something where changes can be managed by other tools.  
> One idea would be to use ldap. Is it possible to access the roles of a given user via searchguard management api when using ldap backend for authorization?

You cannot access or manage ldap roles/users via the management api.

> The alternative idea is to handle everything with client certificates. If we do that, is it enough to define which field shall be used as user name or must this user name then be configured in the internal user database?

this is configurable

> Same question for roles and rights.

roles and rights cannot be stored in a ssl client certificate so you need to use sg\_roles\_mapping.yml here or ldap

> We would want to map the Organizational Unit Name to a role to avoid reconfiguring of searchguard for each change in userbase. Is that possible?

not yet, but we are an open source and happy to accept a PR for that or, if you pay for a search guard license, we can talk about implementing this feature.

> This leads to the next question: must one restart searchguard/elasticsearch when replacing/changing truststore.jks?

yes but there is no need to replace or change truststore.jks because it should only contain the root certificate (and that hopefully only change if its compromised)

> **···**
>
> > Am 07.03.2017 um 10:44 schrieb Me He \<google-work@kampfschnuffel.de\>:
> 
> > best,  
> > Meike
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "Search Guard" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to search-guard+unsubscribe@googlegroups.com.  
> > To post to this group, send email to search-guard@googlegroups.com.  
> > To view this discussion on the web visit [https://groups.google.com/d/msgid/search-guard/7984767f-7469-42c3-b09c-aebe074175d9%40googlegroups.com\](https://groups.google.com/d/msgid/search-guard/7984767f-7469-42c3-b09c-aebe074175d9%40googlegroups.com%5C).  
> > For more options, visit [https://groups.google.com/d/optout\](https://groups.google.com/d/optout%5C).
