Add filter by backend roles setting#2034
Add filter by backend roles setting#2034markdboyd wants to merge 25 commits intoopensearch-project:mainfrom
Conversation
8589a08 to
a2932a3
Compare
| fun doUserBackendRolesMatchResource(userBackendRoles: List<String>, resourceBackendRoles: List<String>): Boolean { | ||
| if (filterByAccessStrategy == FilterByBackendRolesAccessStrategy.INTERSECT.strategy) { | ||
| return resourceBackendRoles.any { it in userBackendRoles } | ||
| } else if (filterByAccessStrategy == FilterByBackendRolesAccessStrategy.ALL.strategy) { |
There was a problem hiding this comment.
@markdboyd with the ALL strategy, what is the intended behavior when a user has all of the same backend roles but also some additional roles? With this implementation, it looks like a user with more roles would not match the resource.
If I'm understanding the use case correctly, are the below behaviors the intention?
user roles = [role1, role2, role3]andresource roles = [role1, role2, role3]should matchuser roles = [role1, role2, role3, role4, role5]andresource roles = [role1, role2, role3]should matchuser roles = [role1, role2, role3]andresource roles = [role1, role2, role3, role4, role5]should not match
There was a problem hiding this comment.
what is the intended behavior when a user has all of the same backend roles but also some additional roles
In this case with the ALL strategy, the user would not have access.
If I'm understanding the use case correctly, are the below behaviors the intention?
- user roles = [role1, role2, role3] and resource roles = [role1, role2, role3] should match
- user roles = [role1, role2, role3, role4, role5] and resource roles = [role1, role2, role3] should match
- user roles = [role1, role2, role3] and resource roles = [role1, role2, role3, role4, role5] should not match
For scenario 2, the behavior would also be not match and the user would not have access
Perhaps ALL would be better named MATCH_EXACTLY to specify this behavior?
There was a problem hiding this comment.
Ah thanks for clarifying. Yeah, EXACT makes sense in my mind given that additional context.
However, that intended behavior seems odd to me. Could you help me understand the use case for not permitting access to the resource when a user has more roles than are necessary?
There was a problem hiding this comment.
@AWSHurneyt - I thought more about this and I agree: ALL should provide access if the user roles contain all of the object backend roles, even if the user has additional roles. So for ALL, the user would have access in scenarios 1 and 2.
I added new logic to handle the ALL strategy. And I added EXACT as a separate strategy where the roles must match exactly with no additional roles
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…s access strategy Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ckend roles Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…mpare sorted lists Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…tting Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…omparing Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
… is all Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
… to clarify logic behavior Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ogic Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ting settings tests Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…es must match exactly Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ategy of exact Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…all is successful when roles are in a different order Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
cb70999 to
fef3f4e
Compare
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Description
This PR adds a new plugin setting,
plugins.alerting.filter_by_backend_roles_access_strategy, which allows users to control how filtering by backend roles works to determine access to alerting objects (monitors). The options for this setting are:exact- Users have access to alerting objects if they have exactly the same (with no additional) backend roles as the user who created the objectintersect- Users have access to alerting objects if they share at least one backend role with the user who created the objectall- Users have access to alerting objects if their backend roles contain all of the backend roles of the user who created the objectRelated Issues
Resolves #1940
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.