-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Mirror privileges over data streams to their backing indices #58381
Merged
danhermann
merged 25 commits into
elastic:master
from
danhermann:grant_privs_to_backing_indices
Jul 3, 2020
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d30476c
Change IndicesPermission::authorize to check parent data stream if re…
danhermann bc0e9b1
add REST test
danhermann 1f03278
add comment to test
danhermann 3c6bac8
Merge branch 'master' into grant_privs_to_backing_indices
elasticmachine bd716a5
Merge branch 'grant_privs_to_backing_indices' of https://github.com/d…
danhermann 6073197
Merge branch 'master' into grant_privs_to_backing_indices
elasticmachine 948209e
Merge branch 'master' into grant_privs_to_backing_indices
elasticmachine e0965e4
recommended security integration implementation
danhermann 80d7caf
add tests for isIndexVisible
danhermann 6caaa1e
add test for resolveAuthorizedIndicesFromRole
danhermann f8305c0
add test for IndicesPermission::authorize
danhermann 233c043
checkstyle!
danhermann dd8794f
improve javadoc
danhermann 79c5e09
add test case for requests not supporting data streams
danhermann b26c874
add includeDataStreams flag to fix failing test
danhermann 2988f7a
unit test fix
danhermann c380031
remove tests that are no longer valid
danhermann 6491913
Merge branch 'master' into grant_privs_to_backing_indices
elasticmachine fa0d1d6
fix failing test
danhermann 12466c5
Merge branch 'master' into grant_privs_to_backing_indices
danhermann 129d01c
fix merge conflict
danhermann 8f1d8ee
Merge branch 'master' into grant_privs_to_backing_indices
elasticmachine 98f222b
fix test
danhermann 022c7c1
fix another test
danhermann 2ba65c9
review comments
danhermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.set.Sets; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.transport.TransportRequest; | ||
import org.elasticsearch.xpack.core.security.authz.AuthorizationEngine; | ||
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor; | ||
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor.IndicesPrivileges; | ||
import org.elasticsearch.xpack.core.security.authz.permission.FieldPermissions; | ||
|
@@ -35,7 +37,7 @@ public class AuthorizedIndicesTests extends ESTestCase { | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to test that RBACEngine.resolveAuthorizedIndicesFromRole:
We need to repeat the tests for when the request works with data streams or not. |
||
public void testAuthorizedIndicesUserWithoutRoles() { | ||
List<String> authorizedIndices = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(Role.EMPTY, "", Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
RBACEngine.resolveAuthorizedIndicesFromRole(Role.EMPTY, getRequestInfo(""), Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
assertTrue(authorizedIndices.isEmpty()); | ||
} | ||
|
||
|
@@ -71,7 +73,7 @@ public void testAuthorizedIndicesUserWithSomeRoles() { | |
CompositeRolesStore.buildRoleFromDescriptors(descriptors, new FieldPermissionsCache(Settings.EMPTY), null, future); | ||
Role roles = future.actionGet(); | ||
List<String> list = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(roles, SearchAction.NAME, metadata.getIndicesLookup()); | ||
RBACEngine.resolveAuthorizedIndicesFromRole(roles, getRequestInfo(SearchAction.NAME), metadata.getIndicesLookup()); | ||
assertThat(list, containsInAnyOrder("a1", "a2", "aaaaaa", "b", "ab")); | ||
assertFalse(list.contains("bbbbb")); | ||
assertFalse(list.contains("ba")); | ||
|
@@ -81,15 +83,15 @@ public void testAuthorizedIndicesUserWithSomeRoles() { | |
|
||
public void testAuthorizedIndicesUserWithSomeRolesEmptyMetadata() { | ||
Role role = Role.builder("role").add(IndexPrivilege.ALL, "*").build(); | ||
List<String> authorizedIndices = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, SearchAction.NAME, Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
List<String> authorizedIndices = RBACEngine.resolveAuthorizedIndicesFromRole(role, getRequestInfo(SearchAction.NAME), | ||
Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
assertTrue(authorizedIndices.isEmpty()); | ||
} | ||
|
||
public void testSecurityIndicesAreRemovedFromRegularUser() { | ||
Role role = Role.builder("user_role").add(IndexPrivilege.ALL, "*").cluster(Set.of("all"), Set.of()).build(); | ||
List<String> authorizedIndices = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, SearchAction.NAME, Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
List<String> authorizedIndices = RBACEngine.resolveAuthorizedIndicesFromRole(role, getRequestInfo(SearchAction.NAME), | ||
Metadata.EMPTY_METADATA.getIndicesLookup()); | ||
assertTrue(authorizedIndices.isEmpty()); | ||
} | ||
|
||
|
@@ -114,7 +116,7 @@ public void testSecurityIndicesAreRestrictedForDefaultRole() { | |
.build(); | ||
|
||
List<String> authorizedIndices = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, SearchAction.NAME, metadata.getIndicesLookup()); | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, getRequestInfo(SearchAction.NAME), metadata.getIndicesLookup()); | ||
assertThat(authorizedIndices, containsInAnyOrder("an-index", "another-index")); | ||
assertThat(authorizedIndices, not(contains(internalSecurityIndex))); | ||
assertThat(authorizedIndices, not(contains(RestrictedIndicesNames.SECURITY_MAIN_ALIAS))); | ||
|
@@ -140,13 +142,21 @@ public void testSecurityIndicesAreNotRemovedFromUnrestrictedRole() { | |
.build(); | ||
|
||
List<String> authorizedIndices = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, SearchAction.NAME, metadata.getIndicesLookup()); | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, getRequestInfo(SearchAction.NAME), metadata.getIndicesLookup()); | ||
assertThat(authorizedIndices, containsInAnyOrder( | ||
"an-index", "another-index", RestrictedIndicesNames.SECURITY_MAIN_ALIAS, internalSecurityIndex)); | ||
|
||
List<String> authorizedIndicesSuperUser = | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, SearchAction.NAME, metadata.getIndicesLookup()); | ||
RBACEngine.resolveAuthorizedIndicesFromRole(role, getRequestInfo(SearchAction.NAME), metadata.getIndicesLookup()); | ||
assertThat(authorizedIndicesSuperUser, containsInAnyOrder( | ||
"an-index", "another-index", RestrictedIndicesNames.SECURITY_MAIN_ALIAS, internalSecurityIndex)); | ||
} | ||
|
||
public static AuthorizationEngine.RequestInfo getRequestInfo(String action) { | ||
return getRequestInfo(TransportRequest.Empty.INSTANCE, action); | ||
} | ||
|
||
public static AuthorizationEngine.RequestInfo getRequestInfo(TransportRequest request, String action) { | ||
return new AuthorizationEngine.RequestInfo(null, request, action); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I would work on the naming and/or javadoc for this to make it clear that such requests over wildcards are meant to (not) expand to data stream names too.