get-role-mappings.asciidoc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. [role="xpack"]
  2. [[security-api-get-role-mapping]]
  3. === Get role mappings API
  4. ++++
  5. <titleabbrev>Get role mappings</titleabbrev>
  6. ++++
  7. Retrieves role mappings.
  8. [[security-api-get-role-mapping-request]]
  9. ==== {api-request-title}
  10. `GET /_security/role_mapping` +
  11. `GET /_security/role_mapping/<name>`
  12. [[security-api-get-role-mapping-prereqs]]
  13. ==== {api-prereq-title}
  14. * To use this API, you must have at least the `read_security` cluster privilege.
  15. [[security-api-get-role-mapping-desc]]
  16. ==== {api-description-title}
  17. Role mappings define which roles are assigned to each user. For more information,
  18. see <<mapping-roles>>.
  19. The role mapping APIs are generally the preferred way to manage role mappings
  20. rather than using <<mapping-roles-file,role mapping files>>.
  21. The get role mappings API cannot retrieve role mappings that are defined
  22. in role mapping files.
  23. [[security-api-get-role-mapping-path-params]]
  24. ==== {api-path-parms-title}
  25. `name`::
  26. (Optional, string) The distinct name that identifies the role mapping. The name
  27. is used solely as an identifier to facilitate interaction via the API; it does
  28. not affect the behavior of the mapping in any way. You can specify multiple
  29. mapping names as a comma-separated list. If you do not specify this
  30. parameter, the API returns information about all role mappings.
  31. [[security-api-get-role-mapping-response-body]]
  32. ==== {api-response-body-title}
  33. A successful call retrieves an object, where the keys are the
  34. names of the request mappings, and the values are the JSON representation of
  35. those mappings. For more information, see
  36. <<role-mapping-resources>>.
  37. [[security-api-get-role-mapping-response-codes]]
  38. ==== {api-response-codes-title}
  39. If there is no mapping with the requested name, the
  40. response will have status code `404`.
  41. [[security-api-get-role-mapping-example]]
  42. ==== {api-examples-title}
  43. The following example retrieves information about the `mapping1` role mapping:
  44. [source,console]
  45. --------------------------------------------------
  46. GET /_security/role_mapping/mapping1
  47. --------------------------------------------------
  48. // TEST[setup:role_mapping]
  49. [source,console-result]
  50. --------------------------------------------------
  51. {
  52. "mapping1": {
  53. "enabled": true,
  54. "roles": [
  55. "user"
  56. ],
  57. "rules": {
  58. "field": {
  59. "username": "*"
  60. }
  61. },
  62. "metadata": {}
  63. }
  64. }
  65. --------------------------------------------------