Skip to content
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

[RAM] Enable read-only users to access rules #167003

Merged

Conversation

umbopepato
Copy link
Member

@umbopepato umbopepato commented Sep 22, 2023

Closes #166613

Summary

Enables users with read privilege on Stack rules to see the rules table and the rule detail page without editing capabilities. Before:

image

After:

image

In case of empty rules lists, the prompt "Create your first rule" was shown, even to users without create permissions:

image

To avoid confusion, read-only users now see the empty table instead:

image

In the rule detail page, users without access to Actions and Connectors now see a missing privileges message under Actions in the details panel instead of No actions and a Forbidden error toast.

image

Finally, the original missing authorization prompt now shows "read" instead of "create":

image

To test

  • Create an Elasticsearch query rule
  • Create a Role with read privilege granted in Stack rules (under Kibana > Management) and assign it to a user
  • Create a test user with the created role
  • Log in as the test user
  • Navigate to Stack Management > Rules
  • Check that the rules table is visible, with create and update actions disabled

Checklist

@umbopepato umbopepato added release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.10.0 v8.11.0 labels Sep 22, 2023
@umbopepato umbopepato marked this pull request as ready for review September 27, 2023 14:17
@umbopepato umbopepato requested review from a team as code owners September 27, 2023 14:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@umbopepato umbopepato requested a review from guskovaue October 3, 2023 12:55
@guskovaue
Copy link
Contributor

LGTM!
But if we are fixing banner for the case when user does not have read rights under the rules tab in this PR. Maybe it'll be valuable to put some banner under the Logs tab as well. What do you think?
Now it looks like this:
Screenshot 2023-10-04 at 10 28 13

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Observability_functional test change LGTM!

);
await retry.waitFor(
'Create rule button is disabled',
async () => !(await testSubjects.isEnabled('createRuleButton'))
Copy link
Member

Choose a reason for hiding this comment

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

Question: How exactly does the assertion work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I inverted the return value of the isEnabled utility to check that the button is disabled. Don't know if there are better utilities for such a case, but it seemed pretty straightforward 🙂

@umbopepato
Copy link
Member Author

LGTM! But if we are fixing banner for the case when user does not have read rights under the rules tab in this PR. Maybe it'll be valuable to put some banner under the Logs tab as well. What do you think? Now it looks like this: Screenshot 2023-10-04 at 10 28 13

Absolutely! We were thinking of addressing this in another PR 🙂

@umbopepato umbopepato added v8.12.0 and removed v8.10.0 labels Oct 6, 2023
@umbopepato umbopepato enabled auto-merge (squash) October 6, 2023 14:20
@umbopepato umbopepato merged commit e49628a into elastic:main Oct 6, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
triggersActionsUi 1.4MB 1.4MB +704.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 6, 2023
Closes elastic#166613

## Summary

Enables users with read privilege on `Stack rules` to see the rules
table and the rule detail page without editing capabilities. Before:

![image](https://github.com/elastic/kibana/assets/18363145/a377819f-b140-41a4-aad9-9f5a5d779d63)

After:

![image](https://github.com/elastic/kibana/assets/18363145/0c1bbf08-0f7b-4778-ae3e-062b0bd49c8f)

In case of empty rules lists, the prompt "Create your first rule" was
shown, even to users without create permissions:

![image](https://github.com/elastic/kibana/assets/18363145/3beaadb5-7b54-473e-9daa-e96c79e5a9f4)

To avoid confusion, read-only users now see the empty table instead:

![image](https://github.com/elastic/kibana/assets/18363145/f35d212a-bc3e-4ee6-a3af-605966efced9)

In the rule detail page, users without access to `Actions and
Connectors` now see a missing privileges message under `Actions` in the
details panel instead of `No actions` and a `Forbidden` error toast.

![image](https://github.com/elastic/kibana/assets/18363145/7d3edeae-3cd0-44c5-be2b-57ba4b54f69e)

Finally, the original missing authorization prompt now shows "read"
instead of "create":

![image](https://github.com/elastic/kibana/assets/18363145/f88b492d-3b20-41ac-a7c7-3cdd7f971ee5)

## To test

- Create an Elasticsearch query rule
- Create a Role with read privilege granted in `Stack rules` (under
Kibana > Management) and assign it to a user
- Create a test user with the created role
- Log in as the test user
- Navigate to Stack Management > Rules
- Check that the rules table is visible, with create and update actions
disabled

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)

---------

Co-authored-by: Xavier Mouligneau <[email protected]>
(cherry picked from commit e49628a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.11

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 6, 2023
# Backport

This will backport the following commits from `main` to `8.11`:
- [[RAM] Enable read-only users to access rules
(#167003)](#167003)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Umberto
Pepato","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-06T16:01:18Z","message":"[RAM]
Enable read-only users to access rules (#167003)\n\nCloses
#166613\r\n\r\n## Summary\r\n\r\nEnables users with read privilege on
`Stack rules` to see the rules\r\ntable and the rule detail page without
editing capabilities.
Before:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/a377819f-b140-41a4-aad9-9f5a5d779d63)\r\n\r\nAfter:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/0c1bbf08-0f7b-4778-ae3e-062b0bd49c8f)\r\n\r\nIn
case of empty rules lists, the prompt \"Create your first rule\"
was\r\nshown, even to users without create
permissions:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/3beaadb5-7b54-473e-9daa-e96c79e5a9f4)\r\n\r\nTo
avoid confusion, read-only users now see the empty table
instead:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f35d212a-bc3e-4ee6-a3af-605966efced9)\r\n\r\nIn
the rule detail page, users without access to `Actions
and\r\nConnectors` now see a missing privileges message under `Actions`
in the\r\ndetails panel instead of `No actions` and a `Forbidden` error
toast.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/7d3edeae-3cd0-44c5-be2b-57ba4b54f69e)\r\n\r\nFinally,
the original missing authorization prompt now shows \"read\"\r\ninstead
of
\"create\":\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f88b492d-3b20-41ac-a7c7-3cdd7f971ee5)\r\n\r\n##
To test\r\n\r\n- Create an Elasticsearch query rule\r\n- Create a Role
with read privilege granted in `Stack rules` (under\r\nKibana >
Management) and assign it to a user\r\n- Create a test user with the
created role\r\n- Log in as the test user\r\n- Navigate to Stack
Management > Rules\r\n- Check that the rules table is visible, with
create and update actions\r\ndisabled\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by:
Xavier Mouligneau
<[email protected]>","sha":"e49628acabcb8c566f9d30a72b88129151f829ee","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v8.11.0","v8.12.0"],"number":167003,"url":"https://github.com/elastic/kibana/pull/167003","mergeCommit":{"message":"[RAM]
Enable read-only users to access rules (#167003)\n\nCloses
#166613\r\n\r\n## Summary\r\n\r\nEnables users with read privilege on
`Stack rules` to see the rules\r\ntable and the rule detail page without
editing capabilities.
Before:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/a377819f-b140-41a4-aad9-9f5a5d779d63)\r\n\r\nAfter:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/0c1bbf08-0f7b-4778-ae3e-062b0bd49c8f)\r\n\r\nIn
case of empty rules lists, the prompt \"Create your first rule\"
was\r\nshown, even to users without create
permissions:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/3beaadb5-7b54-473e-9daa-e96c79e5a9f4)\r\n\r\nTo
avoid confusion, read-only users now see the empty table
instead:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f35d212a-bc3e-4ee6-a3af-605966efced9)\r\n\r\nIn
the rule detail page, users without access to `Actions
and\r\nConnectors` now see a missing privileges message under `Actions`
in the\r\ndetails panel instead of `No actions` and a `Forbidden` error
toast.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/7d3edeae-3cd0-44c5-be2b-57ba4b54f69e)\r\n\r\nFinally,
the original missing authorization prompt now shows \"read\"\r\ninstead
of
\"create\":\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f88b492d-3b20-41ac-a7c7-3cdd7f971ee5)\r\n\r\n##
To test\r\n\r\n- Create an Elasticsearch query rule\r\n- Create a Role
with read privilege granted in `Stack rules` (under\r\nKibana >
Management) and assign it to a user\r\n- Create a test user with the
created role\r\n- Log in as the test user\r\n- Navigate to Stack
Management > Rules\r\n- Check that the rules table is visible, with
create and update actions\r\ndisabled\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by:
Xavier Mouligneau
<[email protected]>","sha":"e49628acabcb8c566f9d30a72b88129151f829ee"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167003","number":167003,"mergeCommit":{"message":"[RAM]
Enable read-only users to access rules (#167003)\n\nCloses
#166613\r\n\r\n## Summary\r\n\r\nEnables users with read privilege on
`Stack rules` to see the rules\r\ntable and the rule detail page without
editing capabilities.
Before:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/a377819f-b140-41a4-aad9-9f5a5d779d63)\r\n\r\nAfter:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/0c1bbf08-0f7b-4778-ae3e-062b0bd49c8f)\r\n\r\nIn
case of empty rules lists, the prompt \"Create your first rule\"
was\r\nshown, even to users without create
permissions:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/3beaadb5-7b54-473e-9daa-e96c79e5a9f4)\r\n\r\nTo
avoid confusion, read-only users now see the empty table
instead:\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f35d212a-bc3e-4ee6-a3af-605966efced9)\r\n\r\nIn
the rule detail page, users without access to `Actions
and\r\nConnectors` now see a missing privileges message under `Actions`
in the\r\ndetails panel instead of `No actions` and a `Forbidden` error
toast.\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/7d3edeae-3cd0-44c5-be2b-57ba4b54f69e)\r\n\r\nFinally,
the original missing authorization prompt now shows \"read\"\r\ninstead
of
\"create\":\r\n\r\n\r\n![image](https://github.com/elastic/kibana/assets/18363145/f88b492d-3b20-41ac-a7c7-3cdd7f971ee5)\r\n\r\n##
To test\r\n\r\n- Create an Elasticsearch query rule\r\n- Create a Role
with read privilege granted in `Stack rules` (under\r\nKibana >
Management) and assign it to a user\r\n- Create a test user with the
created role\r\n- Log in as the test user\r\n- Navigate to Stack
Management > Rules\r\n- Check that the rules table is visible, with
create and update actions\r\ndisabled\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n\r\n---------\r\n\r\nCo-authored-by:
Xavier Mouligneau
<[email protected]>","sha":"e49628acabcb8c566f9d30a72b88129151f829ee"}}]}]
BACKPORT-->

Co-authored-by: Umberto Pepato <[email protected]>
dej611 pushed a commit to dej611/kibana that referenced this pull request Oct 17, 2023
Closes elastic#166613

## Summary

Enables users with read privilege on `Stack rules` to see the rules
table and the rule detail page without editing capabilities. Before:


![image](https://github.com/elastic/kibana/assets/18363145/a377819f-b140-41a4-aad9-9f5a5d779d63)

After:


![image](https://github.com/elastic/kibana/assets/18363145/0c1bbf08-0f7b-4778-ae3e-062b0bd49c8f)

In case of empty rules lists, the prompt "Create your first rule" was
shown, even to users without create permissions:


![image](https://github.com/elastic/kibana/assets/18363145/3beaadb5-7b54-473e-9daa-e96c79e5a9f4)

To avoid confusion, read-only users now see the empty table instead:


![image](https://github.com/elastic/kibana/assets/18363145/f35d212a-bc3e-4ee6-a3af-605966efced9)

In the rule detail page, users without access to `Actions and
Connectors` now see a missing privileges message under `Actions` in the
details panel instead of `No actions` and a `Forbidden` error toast.


![image](https://github.com/elastic/kibana/assets/18363145/7d3edeae-3cd0-44c5-be2b-57ba4b54f69e)

Finally, the original missing authorization prompt now shows "read"
instead of "create":


![image](https://github.com/elastic/kibana/assets/18363145/f88b492d-3b20-41ac-a7c7-3cdd7f971ee5)

## To test

- Create an Elasticsearch query rule
- Create a Role with read privilege granted in `Stack rules` (under
Kibana > Management) and assign it to a user
- Create a test user with the created role
- Log in as the test user
- Navigate to Stack Management > Rules
- Check that the rules table is visible, with create and update actions
disabled

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)

---------

Co-authored-by: Xavier Mouligneau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.11.0 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read only users cannot see rules in Stack Management
7 participants