Skip to content

Add filter by backend roles access strategy setting - #1146

Merged
AWSHurneyt merged 40 commits into
opensearch-project:mainfrom
cloud-gov:add-filter-by-access-strategy-setting
Jul 20, 2026
Merged

Add filter by backend roles access strategy setting#1146
AWSHurneyt merged 40 commits into
opensearch-project:mainfrom
cloud-gov:add-filter-by-access-strategy-setting

Conversation

@markdboyd

@markdboyd markdboyd commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a new plugin setting, plugins.notifications.general.filter_by_backend_roles_access_strategy, which allows users to control how filtering by backend roles works to determine access to notification objects (e.g. SMTP senders, email recipient groups, channels). 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

Closes #1079

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 `test get smtp sender has access with filter by backend roles enabled`() {

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.

I think we need the integration tests from here onwards for at least config type to prove that access controls work as expected when filter_by_backend_roles: true, including in conjunction with the filter_by_backend_roles_access_strategy setting..

I'm debating whether we need to replicate these tests for other config objects (email groups, channels, etc), or whether these tests plus the tests in UserAccessManagerTests.kt are sufficient

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.

Ideally, it would be nice to have that coverage.

In my opinion though, the higher priority would be having integ test coverage for editing an asset with/without the necessary backend roles (example edit channel test), deleting an asset with/without the necessary backend roles (example delete channel test), and sending test notification messages with/without the necessary backend roles (example send test message test).

Properly filtering out assets (e.g., channel configs) based on backend roles should prevent a user from performing those actions via the UI, but they could still try by using curl commands/devtools if they happen to know the ID for the asset.

/**
* Backend roles must be exactly equal to have access
*/
ALL("all")

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.

For visibility to other reviewers, we're discussing adjusting the name of this strategy away from ALL in this thread.
opensearch-project/alerting#2034 (comment)

@AWSHurneyt

Copy link
Copy Markdown
Collaborator

@markdboyd could you rebase your branch from opensearch-project:main, and resolve the conflicts? I'd like to see whether the checks pass.

@markdboyd
markdboyd force-pushed the add-filter-by-access-strategy-setting branch 2 times, most recently from 0a0d24e to 998d8d3 Compare March 31, 2026 20:12
@markdboyd

Copy link
Copy Markdown
Contributor Author

@AWSHurneyt AWSHurneyt left a comment

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.

Side note:
The PR description could use a little updating to reference the 3 strategies and their function.

}
}

fun `test get smtp sender has access with filter by backend roles enabled`() {

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.

Ideally, it would be nice to have that coverage.

In my opinion though, the higher priority would be having integ test coverage for editing an asset with/without the necessary backend roles (example edit channel test), deleting an asset with/without the necessary backend roles (example delete channel test), and sending test notification messages with/without the necessary backend roles (example send test message test).

Properly filtering out assets (e.g., channel configs) based on backend roles should prevent a user from performing those actions via the UI, but they could still try by using curl commands/devtools if they happen to know the ID for the asset.

@markdboyd
markdboyd force-pushed the add-filter-by-access-strategy-setting branch from 164aacf to b475a49 Compare June 12, 2026 16:31
@markdboyd

Copy link
Copy Markdown
Contributor Author

@AWSHurneyt OK, I added tests for:

  • editing and deleting SMTP account with and without access
  • creating, getting, editing, and deleting an email group without access
  • sending slack notification messages with and without access

Is there additional test coverage that you would like me to add?

@markdboyd
markdboyd force-pushed the add-filter-by-access-strategy-setting branch 2 times, most recently from 9134c35 to 82bce43 Compare June 17, 2026 21:02
markdboyd added 10 commits June 18, 2026 16:12
…access strategy is exact

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>
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>
…ies for get and update operations on email notification channels

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-access-strategy-setting branch from 82bce43 to d23adaf Compare June 18, 2026 20:12
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ests

Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
@cwperks

cwperks commented Jul 8, 2026

Copy link
Copy Markdown
Member

@markdboyd apologies for the delay on getting comments to this PR and the alerting PR. Overall the code changes look good to me and it makes sense to adding this setting to working with filter_by_backend_roles for any cluster admin wanting to use backend roles to control visibility of resources created from the notifications and alerting plugins. Along with this PR we should also submit PRs to the https://github.com/opensearch-project/documentation-website repo to document the new plugin settings.

DEFAULT_FILTER_BY_BACKEND_ROLES_ACCESS_STRATEGY,
FilterByBackendRolesAccessStrategyValidator(),
NodeScope,
Dynamic

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@markdboyd Let's also add Sensitive into this vararg list of settings properties. Sensitive would mean that the cluster setting is only toggleable by a security admin vs. any user w/ cluster:admin/settings/put. Its not quite fine grained access to settings, but its a 2 tier system to differentiate between security admin vs other users.

RestStatus.OK.status,
updateUserClient
)
Thread.sleep(1000)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use Awaitility (or similar for Kotlin) to wait for condition and avoid Thread.sleep?

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.

I opted to just remove the Thread.sleep and it seems like the tests are still passing. I suspect that they were put in place to handle some race conditions, but perhaps they are not necessary anymore

try {
val configId = createConfigWithRequestJsonString(createRequestJsonString, userClient!!)
Assert.assertNotNull(configId)
Thread.sleep(1000)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, prefer Awaitility to Thread.sleep

val (emailGroupConfig, createEmailGroupRequestJsonString) = createTestEmailGroup()

val getUser = "getUser"
val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see a lot of this code repeated. Not a blocker for these PRs, but I'd love to extract this out to a helper method where you can supply username, password and get a client...or get a client and pass username and password at the request level.

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.

Addressed in 823f1d0. I did notice that there was a buildClient helper function already: https://github.com/opensearch-project/notifications/blob/main/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt#L108. However, since it reads the username/password via System.getProperty, it didn't seem usable in these integration tests where we need to create a client based on a dynamic username/password.

…ude the Sensitive property

Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…estClient

Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
@markdboyd

Copy link
Copy Markdown
Contributor Author

@cwperks Here is the related documentation changes: opensearch-project/documentation-website#12794

@AWSHurneyt

Copy link
Copy Markdown
Collaborator

Confirmed with @cwperks offline that his comments have been addressed. Merging.

@AWSHurneyt
AWSHurneyt merged commit c013118 into opensearch-project:main Jul 20, 2026
14 checks passed
@markdboyd
markdboyd deleted the add-filter-by-access-strategy-setting branch July 20, 2026 18:37
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 user access

3 participants