OpenSearch/x-pack/docs/en/security/authorization/alias-privileges.asciidoc

104 lines
3.4 KiB
Plaintext
Raw Normal View History

[role="xpack"]
[[securing-aliases]]
=== Granting privileges for indices and aliases
Elasticsearch allows to execute operations against {ref}/indices-aliases.html[index aliases],
which are effectively virtual indices. An alias points to one or more indices,
holds metadata and potentially a filter. The {es} {security-features} treat
aliases and indices
the same. Privileges for indices actions are granted on specific indices or
aliases. In order for an indices action to be authorized, the user that executes
it needs to have permissions for that action on all the specific indices or
aliases that the request relates to.
Let's look at an example. Assuming we have an index called `2015`, an alias that
points to it called `current_year`, and a user with the following role:
[source,js]
--------------------------------------------------
{
"names" : [ "2015" ],
"privileges" : [ "read" ]
}
--------------------------------------------------
// NOTCONSOLE
The user attempts to retrieve a document from `current_year`:
[source,shell]
-------------------------------------------------------------------------------
GET /current_year/event/1
-------------------------------------------------------------------------------
// CONSOLE
// TEST[s/^/PUT 2015\n{"aliases": {"current_year": {}}}\nPUT 2015\/event\/1\n{}\n/]
The above request gets rejected, although the user has `read` privilege on the
concrete index that the `current_year` alias points to. The correct permission
would be as follows:
[source,js]
--------------------------------------------------
{
"names" : [ "current_year" ],
"privileges" : [ "read" ]
}
--------------------------------------------------
// NOTCONSOLE
[float]
==== Managing aliases
Unlike creating indices, which requires the `create_index` privilege, adding,
removing and retrieving aliases requires the `manage` permission. Aliases can be
added to an index directly as part of the index creation:
[source,shell]
-------------------------------------------------------------------------------
Update the default for include_type_name to false. (#37285) * Default include_type_name to false for get and put mappings. * Default include_type_name to false for get field mappings. * Add a constant for the default include_type_name value. * Default include_type_name to false for get and put index templates. * Default include_type_name to false for create index. * Update create index calls in REST documentation to use include_type_name=true. * Some minor clean-ups around the get index API. * In REST tests, use include_type_name=true by default for index creation. * Make sure to use 'expression == false'. * Clarify the different IndexTemplateMetaData toXContent methods. * Fix FullClusterRestartIT#testSnapshotRestore. * Fix the ml_anomalies_default_mappings test. * Fix GetFieldMappingsResponseTests and GetIndexTemplateResponseTests. We make sure to specify include_type_name=true during xContent parsing, so we continue to test the legacy typed responses. XContent generation for the typeless responses is currently only covered by REST tests, but we will be adding unit test coverage for these as we implement each typeless API in the Java HLRC. This commit also refactors GetMappingsResponse to follow the same appraoch as the other mappings-related responses, where we read include_type_name out of the xContent params, instead of creating a second toXContent method. This gives better consistency in the response parsing code. * Fix more REST tests. * Improve some wording in the create index documentation. * Add a note about types removal in the create index docs. * Fix SmokeTestMonitoringWithSecurityIT#testHTTPExporterWithSSL. * Make sure to mention include_type_name in the REST docs for affected APIs. * Make sure to use 'expression == false' in FullClusterRestartIT. * Mention include_type_name in the REST templates docs.
2019-01-14 16:08:01 -05:00
PUT /2015?include_type_name=true
{
"aliases" : {
"current_year" : {}
}
}
-------------------------------------------------------------------------------
// CONSOLE
or via the dedicated aliases api if the index already exists:
[source,shell]
-------------------------------------------------------------------------------
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "2015", "alias" : "current_year" } }
]
}
-------------------------------------------------------------------------------
// CONSOLE
// TEST[s/^/PUT 2015\n/]
The above requests both require the `manage` privilege on the alias name as well
as the targeted index, as follows:
[source,js]
--------------------------------------------------
{
"names" : [ "20*", "current_year" ],
"privileges" : [ "manage" ]
}
--------------------------------------------------
// NOTCONSOLE
The index aliases api also allows also to delete aliases from existing indices.
The privileges required for such a request are the same as above. Both index and
alias need the `manage` permission.
[float]
==== Filtered aliases
Aliases can hold a filter, which allows to select a subset of documents that can
be accessed out of all the documents that the physical index contains. These
filters are not always applied and should not be used in place of
<<document-level-security, document level security>>.