Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Add include_data_streams flag for authorization #59008

Merged
merged 5 commits into from
Jul 3, 2020

Conversation

danhermann
Copy link
Contributor

Most of the work around the addition of an includeDataStreams flag was done in #58381. The remainder of this PR adds the flag to the appropriate request classes, updates IndexNameExpressionResolver to rely on the flag rather than a separate boolean flag, and updates tests.

This PR adds an includeDataStreams flag to the IndicesRequest interface so that it is available when AuthorizationEngine::loadAuthorizedIndices is called. This is necessary to avoid different behaviors when security is enabled and disabled.

The disparate behavior is described in the referenced issue. When a GET */_alias request (or any other request that does not operate on data streams) is sent without security enabled, any data streams present are ignored by the IndexNameExpressionResolver class and the correct HTTP 200 response is returned.

When security is enabled, the star in GET */_alias is first resolved to all authorized indices, aliases, and data streams. Because the _alias endpoint does not understand data streams, the first data stream it encounters among the list of authorized indices is treated as an alias and an incorrect 404 for "unknown alias" is returned.

This PR changes AuthorizationService to selectively exclude (in the case of most requests) or include (and the case of ResolveIndexAction.Request and other requests that opt in) data streams during the authorized index resolution phase.

Especially interested in feedback from @elastic/es-security.

Fixes #57712

Relates to #53100

Backport of #58154

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Data streams)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Jul 3, 2020
@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/default-distro

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/oss-distro-docs

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/1

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@@ -207,7 +207,7 @@ public ClusterState execute(ClusterState currentState) {
throw new ConcurrentSnapshotExecutionException(repositoryName, snapshotName, " a snapshot is already running");
}
// Store newSnapshot here to be processed in clusterStateProcessed
List<String> indices = Arrays.asList(indexNameExpressionResolver.concreteIndexNames(currentState, request));
indices = Arrays.asList(indexNameExpressionResolver.concreteIndexNames(currentState, request));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 , but luckily assertions tripped!

assertEquals(1, indices.length);
assertEquals(backingIndex.getIndex().getName(), indices[0]);
}
//{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that in an earlier commit. The backport of #57900 will un-comment it.

@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

1 similar comment
@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@danhermann danhermann merged commit c1781bc into elastic:7.x Jul 3, 2020
@danhermann danhermann deleted the backport_7x_58154_ds_auth branch July 6, 2020 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants