Add filter by backend roles access strategy setting - #1146
Conversation
11e01f5 to
306f22e
Compare
| } | ||
| } | ||
|
|
||
| fun `test get smtp sender has access with filter by backend roles enabled`() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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)
|
@markdboyd could you rebase your branch from opensearch-project:main, and resolve the conflicts? I'd like to see whether the checks pass. |
0a0d24e to
998d8d3
Compare
|
@AWSHurneyt - OK, I've rebased from https://github.com/opensearch-project/notifications/tree/main |
fe46f99 to
9e2f308
Compare
AWSHurneyt
left a comment
There was a problem hiding this comment.
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`() { |
There was a problem hiding this comment.
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.
164aacf to
b475a49
Compare
|
@AWSHurneyt OK, I added tests for:
Is there additional test coverage that you would like me to add? |
9134c35 to
82bce43
Compare
…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>
82bce43 to
d23adaf
Compare
Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
…ests Signed-off-by: Mark Boyd <mark.boyd@gsa.gov>
|
@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 |
| DEFAULT_FILTER_BY_BACKEND_ROLES_ACCESS_STRATEGY, | ||
| FilterByBackendRolesAccessStrategyValidator(), | ||
| NodeScope, | ||
| Dynamic |
There was a problem hiding this comment.
@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) |
There was a problem hiding this comment.
Can we use Awaitility (or similar for Kotlin) to wait for condition and avoid Thread.sleep?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Same here, prefer Awaitility to Thread.sleep
| val (emailGroupConfig, createEmailGroupRequestJsonString) = createTestEmailGroup() | ||
|
|
||
| val getUser = "getUser" | ||
| val getUserClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), getUser, password) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
|
@cwperks Here is the related documentation changes: opensearch-project/documentation-website#12794 |
|
Confirmed with @cwperks offline that his comments have been addressed. Merging. |
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 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
Closes #1079
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.