alias-privileges.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. [role="xpack"]
  2. [[securing-aliases]]
  3. === Granting privileges for data streams and aliases
  4. {es} {security-features} allow you to secure operations executed against
  5. <<data-streams,data streams>> and <<aliases,aliases>>.
  6. [[data-stream-privileges]]
  7. ==== Data stream privileges
  8. // tag::data-stream-security[]
  9. Use <<privileges-list-indices,index privileges>> to control access to a data
  10. stream. Granting privileges on a data stream grants the same privileges on its
  11. backing indices.
  12. // end::data-stream-security[]
  13. For example, `my-data-stream` consists of two backing indices:
  14. `.ds-my-data-stream-2099.03.07-000001` and
  15. `.ds-my-data-stream-2099.03.08-000002`.
  16. A user is granted the `read` privilege to `my-data-stream`.
  17. [source,js]
  18. --------------------------------------------------
  19. {
  20. "names" : [ "my-data-stream" ],
  21. "privileges" : [ "read" ]
  22. }
  23. --------------------------------------------------
  24. // NOTCONSOLE
  25. Because the user is automatically granted the same privileges to the stream's
  26. backing indices, the user can retrieve a document directly from
  27. `.ds-my-data-stream-2099.03.08-000002`:
  28. ////
  29. [source,console]
  30. ----
  31. PUT my-index/_doc/2
  32. {
  33. "my-field": "foo"
  34. }
  35. ----
  36. ////
  37. [source,console]
  38. ----
  39. GET .ds-my-data-stream-2099.03.08-000002/_doc/2
  40. ----
  41. // TEST[continued]
  42. // TEST[s/.ds-my-data-stream-2099.03.08-000002/my-index/]
  43. Later `my-data-stream` <<manually-roll-over-a-data-stream,rolls over>>. This
  44. creates a new backing index: `.ds-my-data-stream-2099.03.09-000003`. Because the
  45. user still has the `read` privilege for `my-data-stream`, the user can retrieve
  46. documents directly from `.ds-my-data-stream-2099.03.09-000003`:
  47. [source,console]
  48. ----
  49. GET .ds-my-data-stream-2099.03.09-000003/_doc/2
  50. ----
  51. // TEST[continued]
  52. // TEST[s/.ds-my-data-stream-2099.03.09-000003/my-index/]
  53. [[index-alias-privileges]]
  54. ==== Alias privileges
  55. Use <<privileges-list-indices,index privileges>> to control access to an
  56. <<aliases,alias>>. Privileges on an index or data stream do not grant privileges
  57. on its aliases. For information about managing aliases, see <<aliases>>.
  58. IMPORTANT: Don't use <<filter-alias,filtered aliases>> in place of
  59. <<document-level-security,document level security>>. {es} doesn't always apply
  60. alias filters.
  61. For example, the `current_year` alias points only to the `2015` index. A user is
  62. granted the `read` privilege for the `2015` index.
  63. [source,js]
  64. ----
  65. {
  66. "names" : [ "2015" ],
  67. "privileges" : [ "read" ]
  68. }
  69. ----
  70. // NOTCONSOLE
  71. When the user attempts to retrieve a document from the `current_year` alias,
  72. {es} rejects the request.
  73. [source,console]
  74. ----
  75. GET current_year/_doc/1
  76. ----
  77. // TEST[s/^/PUT 2015\n{"aliases": {"current_year": {}}}\nPUT 2015\/_doc\/1\n{}\n/]
  78. To retrieve documents from `current_year`, the user must have the `read` index
  79. privilege for the alias.
  80. [source,js]
  81. ----
  82. {
  83. "names" : [ "current_year" ],
  84. "privileges" : [ "read" ]
  85. }
  86. ----
  87. // NOTCONSOLE