role-mapping-resources.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. [role="xpack"]
  2. [[role-mapping-resources]]
  3. === Role mapping resources
  4. A role mapping resource has the following properties:
  5. `enabled`::
  6. (boolean) Mappings that have `enabled` set to `false` are ignored when role
  7. mapping is performed.
  8. `metadata`::
  9. (object) Additional metadata that helps define which roles are assigned to each
  10. user. Within the `metadata` object, keys beginning with `_` are reserved for
  11. system usage.
  12. `roles`::
  13. (list) A list of roles that are granted to the users that match the role mapping
  14. rules.
  15. `rules`::
  16. (object) The rules that determine which users should be matched by the mapping.
  17. A rule is a logical condition that is expressed by using a JSON DSL. The DSL supports the following rule types:
  18. `any`:::
  19. (array of rules) If *any* of its children are true, it evaluates to `true`.
  20. `all`:::
  21. (array of rules) If *all* of its children are true, it evaluates to `true`.
  22. `field`:::
  23. (object) See <<mapping-roles-rule-field>>.
  24. `except`::
  25. (object) A single rule as an object. Only valid as a child of an `all` rule. If
  26. its child is `false`, the `except` is `true`.
  27. [float]
  28. [[mapping-roles-rule-field]]
  29. ==== Field rules
  30. The `field` rule is the primary building block for a role mapping expression.
  31. It takes a single object as its value and that object must contain a single
  32. member with key _F_ and value _V_. The field rule looks up the value of _F_
  33. within the user object and then tests whether the user value _matches_ the
  34. provided value _V_.
  35. The value specified in the field rule can be one of the following types:
  36. [cols="2,5,3m"]
  37. |=======================
  38. | Type | Description | Example
  39. | Simple String | Exactly matches the provided value. | "esadmin"
  40. | Wildcard String | Matches the provided value using a wildcard. | "*,dc=example,dc=com"
  41. | Regular Expression | Matches the provided value using a
  42. {ref}/regexp-syntax.html[Lucene regexp]. | "/.\*-admin[0-9]*/"
  43. | Number | Matches an equivalent numerical value. | 7
  44. | Null | Matches a null or missing value. | null
  45. | Array | Tests each element in the array in
  46. accordance with the above definitions.
  47. If _any_ of elements match, the match is successful. | ["admin", "operator"]
  48. |=======================
  49. [float]
  50. ===== User fields
  51. The _user object_ against which rules are evaluated has the following fields:
  52. `username`::
  53. (string) The username by which the {es} {security-features} knows this user. For
  54. example, `"username": "jsmith"`.
  55. `dn`::
  56. (string) The _Distinguished Name_ of the user. For example, `"dn": "cn=jsmith,ou=users,dc=example,dc=com",`.
  57. `groups`::
  58. (array of strings) The groups to which the user belongs. For example, `"groups" : [ "cn=admin,ou=groups,dc=example,dc=com","cn=esusers,ou=groups,dc=example,dc=com ]`.
  59. `metadata`::
  60. (object) Additional metadata for the user. For example, `"metadata": { "cn": "John Smith" }`.
  61. `realm`::
  62. (object) The realm that authenticated the user. The only field in this object is the realm name. For example, `"realm": { "name": "ldap1" }`.
  63. The `groups` field is multi-valued; a user can belong to many groups. When a
  64. `field` rule is applied against a multi-valued field, it is considered to match
  65. if _at least one_ of the member values matches. For example, the following rule
  66. matches any user who is a member of the `admin` group, regardless of any
  67. other groups they belong to:
  68. [source, js]
  69. ------------------------------------------------------------
  70. { "field" : { "groups" : "admin" } }
  71. ------------------------------------------------------------
  72. // NOTCONSOLE
  73. For additional realm-specific details, see
  74. {stack-ov}/mapping-roles.html#ldap-role-mapping[Mapping Users and Groups to Roles].