# Issue with role permissions for user role mapping with AAD

**URL:** <https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987>\
**Category:** APM\
**Tags:** elastic-stack-security, ui\
**Created:** [October 19, 2022, 11:14am UTC](https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987 "2022-10-19T11:14:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gauravthakur02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gauravthakur02/32/100235_2.png) [@gauravthakur02](https://discuss.elastic.co/u/gauravthakur02)\
**Post date:** [October 19, 2022, 11:14am UTC](https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987/1 "2022-10-19T11:14:43Z")

</div>

Kibana version: 8.4.2

Elasticsearch version: 8.4.2

APM Server version: 8.4.2

APM Agent language and version: Java Agent, Version 1.33.0

Browser version: Microsoft Edge, Version 106.0.1370.47

Fresh install or upgraded from other version? Fresh install

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

In order to allow users to login after being authenticated to AAD. For this I created an Enterprise Application in AAD and configured SAML with my Elastic Cloud deployment.  
Then I created role-mapping for "superuser", "editor" and "reader". The same value has been assigned to App Role in the Enterprise Application of Azure Active Directory (AAD). The user added to the Enterprise Application are able to login to the Kibana dashboard using the AAD.

However, when the user with role-mapped as "superuser", "editor" and "reader" tries to access APM, dashboard and Discover tab is getting the below error message:  
Error fetching fields for data view -elastic-cloud-logs-,.alerts-security.alerts-default,apm--transaction,auditbeat-,endgame-,filebeat-,logs-,packetbeat-,traces-apm,winlogbeat-\* (ID: security-solution-default)

[object Object]: security\_exception: [security\_exception] Reason: action [indices:data/read/field\_caps] is unauthorized for user [Gaurav.Kumar1@landmarkgroup.com] with roles [reader,kibana\_admin], this action is granted by the index privileges [view\_index\_metadata,manage,read,all]

The logged in user has been added to App Role "superuser". Ideally this user should have all the permission to administrate. The same is happening for users in App roles "editor" and "viewer".

Also, please note that we want to avoid giving "kibana\_admin" permission to users who are "editor" and "viewer".

Errors in browser console (if relevant):

Error fetching fields for data view -elastic-cloud-logs-,.alerts-security.alerts-default,apm--transaction,auditbeat-,endgame-,filebeat-,logs-,packetbeat-,traces-apm,winlogbeat-\* (ID: security-solution-default)

[object Object]: security\_exception: [security\_exception] Reason: action [indices:data/read/field\_caps] is unauthorized for user [Gaurav.Kumar1@landmarkgroup.com] with roles [reader,kibana\_admin], this action is granted by the index privileges [view\_index\_metadata,manage,read,all]

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74fa31d8956d3a8675a1837a5c199adb128976fd.png)

---

<div class="post-metadata">

**Author:** ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)\
**Post date:** [October 24, 2022, 12:01am UTC](https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987/2 "2022-10-24T00:01:02Z")

</div>

> [@gauravthakur02](#):
>
> action [indices:data/read/field\_caps] is unauthorized for user [Gaurav.Kumar1@landmarkgroup.com] with roles [reader,kibana\_admin], this action is granted by the index privileges [view\_index\_metadata,manage,read,all]

The error message says your user have only the roles `reader` and `kibana_admin`. It does not have the `superuser` role. It's eitehr a role mapping problem. Or it might be a caching problem which can be solved by [clearing the realm cache](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) with something like

```auto
POST /_security/realm/*/_clear_cache

```

---

<div class="post-metadata">

**Author:** ![Loran\_Fininure](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@Loran\_Fininure](https://discuss.elastic.co/u/Loran_Fininure)\
**Post date:** [October 25, 2022, 1:46pm UTC](https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987/3 "2022-10-25T13:46:33Z")

</div>

We also had a similar issue after upgrading to major version 8. Even as superuser we got this error.  
Our issue was similar to yours and [Receiving org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed after 7.17.1 to 8.2.3 upgrade](https://discuss.elastic.co/t/receiving-org-elasticsearch-action-search-searchphaseexecutionexception-all-shards-failed-after-7-17-1-to-8-2-3-upgrade/309419)

We were able to resolve it by removing an excess comma within the data view definition.  
In Stack Management -\> Data Views we searched for the ID given in the error message. Editing this data view showed that Kibana was not able to correctly parse the given index pattern due to the additional comma. Once fixed it showed the correct indices on the right hand side.  
After saving the data view the issue was resolved for us.

Seeing your error, I think there may be something wrong with the data view too, unless you have indices start with a dash (as the pattern begins with -_elastic-cloud-logs-_ in the error message)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 15, 2022, 9:47am UTC](https://discuss.elastic.co/t/issue-with-role-permissions-for-user-role-mapping-with-aad/316987/4 "2022-11-15T09:47:30Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
