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

[Alerting] Restricting alerting health API to users with access to rules #118932

Merged
merged 4 commits into from
Nov 23, 2021

Conversation

ymao1
Copy link
Contributor

@ymao1 ymao1 commented Nov 17, 2021

Addresses part of #102100

Summary

Added a check to the alerting framework health API to ensure that users have access to at least one rule type before providing health information. Takes advantage of the existing list_rule_types API which returns all rule types that a user has access to.

To Verify

  • Create a role that does not have access to any rule type. Create a user for that role
  • Verify that when accessing /api/alerting/_health as user, user receives 403 Forbidden response
  • Update role to allow access to one or more rule types
  • Verify that user with updated role can successfully access /api/alerting/_health

Checklist

@ymao1 ymao1 changed the title Adding access check to health API [Alerting] Restricting alerting health API to users with access to rules Nov 19, 2021
@ymao1 ymao1 self-assigned this Nov 19, 2021
@ymao1 ymao1 added Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.1.0 labels Nov 19, 2021
@ymao1 ymao1 marked this pull request as ready for review November 19, 2021 19:40
@ymao1 ymao1 requested a review from a team as a code owner November 19, 2021 19:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@ymao1
Copy link
Contributor Author

ymao1 commented Nov 19, 2021

@elasticmachine merge upstream

@ymao1
Copy link
Contributor Author

ymao1 commented Nov 22, 2021

@elasticmachine merge upstream

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

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

Changes LGTM, but I didn't find any comment under the related issue, which will lead to this solution. As I understood, this is just a partial restriction (for the users which do not have access to any rule type) and it doesn't answer all the questions from the related issue. I assume it was a verbal discussion, but it would be nice to provide the comment or document it somewhere.

@ymao1
Copy link
Contributor Author

ymao1 commented Nov 23, 2021

Changes LGTM, but I didn't find any comment under the related issue, which will lead to this solution. As I understood, this is just a partial restriction (for the users which do not have access to any rule type) and it doesn't answer all the questions from the related issue. I assume it was a verbal discussion, but it would be nice to provide the comment or document it somewhere.

@YulNaumenko Thanks for the review! Can you clarify why you consider this just a partial restriction and which questions it doesn't answer from the related issue? Believe there were several discussions during triage where it was discussed that having this API open to all users was considered a bug and that this should be restricted to users of alerting. Is there something more that this PR can do to address the issue?

@YulNaumenko
Copy link
Contributor

YulNaumenko commented Nov 23, 2021

@YulNaumenko Thanks for the review! Can you clarify why you consider this just a partial restriction and which questions it doesn't answer from the related issue? Believe there were several discussions during triage where it was discussed that having this API open to all users was considered a bug and that this should be restricted to users of alerting.

I think current PR is an elegant solution for the problem with a public access to the health API. Only one concern I had is about loosing track about agreement on the approach. Basically I was confused by the last comment #102100 (comment) which proposed to do something different.

Is there something more that this PR can do to address the issue?

I don't know if something is needed to be addressed. This telemetry PR #119349 is also related to the issue, so I'm wonder if something more is needed in the future.

@ymao1
Copy link
Contributor Author

ymao1 commented Nov 23, 2021

@YulNaumenko Gotcha. Sorry for the confusion. This PR was meant to address Should the alerting framework health API work only for users who access the alerting APIs?, which was not discussed in the issue due to it being a straightforward answer (Yes) and a straightforward approach. The discussion in the issue and the last comment was surrounding the task manager health API, where we decided not to add the restriction for now and instead add telemetry to determine how many users would be affected.

@ymao1
Copy link
Contributor Author

ymao1 commented Nov 23, 2021

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @ymao1

@ymao1 ymao1 merged commit eb3e329 into elastic:main Nov 23, 2021
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 23, 2021
dmlemeshko pushed a commit that referenced this pull request Nov 29, 2021
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
@ymao1 ymao1 deleted the alerting/restrict-apis branch January 27, 2022 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants