Skip to content

Add filter by backend roles setting#2034

Open
markdboyd wants to merge 25 commits intoopensearch-project:mainfrom
cloud-gov:add-filter-by-backend-roles-setting
Open

Add filter by backend roles setting#2034
markdboyd wants to merge 25 commits intoopensearch-project:mainfrom
cloud-gov:add-filter-by-backend-roles-setting

Conversation

@markdboyd
Copy link
Copy Markdown
Contributor

@markdboyd markdboyd commented Mar 6, 2026

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 object
  • intersect - Users have access to alerting objects if they share at least one backend role with the user who created the object
  • all - Users have access to alerting objects if their backend roles contain all of the backend roles of the user who created the object

Related Issues

Resolves #1940

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

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) {
Copy link
Copy Markdown
Collaborator

@AWSHurneyt AWSHurneyt Mar 20, 2026

Choose a reason for hiding this comment

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

@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?

  1. user roles = [role1, role2, role3] and resource roles = [role1, role2, role3] should match
  2. user roles = [role1, role2, role3, role4, role5] and resource roles = [role1, role2, role3] should match
  3. user roles = [role1, role2, role3] and resource roles = [role1, role2, role3, role4, role5] should not match

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AWSHurneyt

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?

  1. user roles = [role1, role2, role3] and resource roles = [role1, role2, role3] should match
  2. user roles = [role1, role2, role3, role4, role5] and resource roles = [role1, role2, role3] should match
  3. 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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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>
@markdboyd markdboyd force-pushed the add-filter-by-backend-roles-setting branch from cb70999 to fef3f4e Compare March 31, 2026 19:07
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add setting to control access to alerting objects by backend roles

2 participants