Skip to content

Permission check for Alertmanager#595

Merged
vincent-olivert-riera merged 2 commits intoline:masterfrom
hoangpn:feature/permission_check_for_alertmanager
Jun 3, 2025
Merged

Permission check for Alertmanager#595
vincent-olivert-riera merged 2 commits intoline:masterfrom
hoangpn:feature/permission_check_for_alertmanager

Conversation

@hoangpn
Copy link
Contributor

@hoangpn hoangpn commented May 27, 2025

Currently, the AlertReceiver API can be called without authentication or authorization, even though it should only be called from internal services like Alertmanager. Therefore, we have added logic to require authentication and the corresponding permission "alert_trigger" for this API.
Before adding this logic, I had to create a custom DRF's permission class to handle checking specific permission.
I also added a detailed instruction for setting Alertmanager in the docker/alertmanager.yml file.

@hoangpn hoangpn requested a review from a team as a code owner May 27, 2025 04:14
@hoangpn hoangpn changed the title Feature/permission check for alertmanager Permission check for Alertmanager May 29, 2025
Copy link
Contributor

@vincent-olivert-riera vincent-olivert-riera left a comment

Choose a reason for hiding this comment

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

I have finished my review. This PR is a nice improvement in terms of security. Overall looks good, but I have made some requests. Please have a look.

Copy link
Contributor

@vincent-olivert-riera vincent-olivert-riera left a comment

Choose a reason for hiding this comment

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

LGTM, but this PR requires the feature for creating API tokens.
I will ask you to rebase it on master after the other PR is merged.
Remember to squash all the fixup commits when you do the rebase.

@vincent-olivert-riera
Copy link
Contributor

LGTM, but this PR requires the feature for creating API tokens. I will ask you to rebase it on master after the other PR is merged. Remember to squash all the fixup commits when you do the rebase.

@hoangpn , the other PR has been merged. Could you please do this? Thanks in advance.

Introduced the "PromgenModelPermissions" class to handle custom permission checks
of a user for a Django REST Framework API.
- Ensures that users are authenticated before checking permissions.
- Validates that "permission_required" is required and iterable.
- Supports both "any_perm" and "all_perms" logic for permission evaluation.
This change enhances flexibility and security in permission handling for views.
@hoangpn hoangpn force-pushed the feature/permission_check_for_alertmanager branch from 19f34c7 to 8b0d658 Compare June 3, 2025 09:31
Currently, the AlertReceiver API can be called without authentication or authorization,
even though it should only be called from internal services like Alertmanager.
Therefore, we have added logic to require authentication and the corresponding
permission "alert_trigger" for this API. To set up AlertManager, please follow
the detailed instructions in the docker/alertmanager.yml file.
@hoangpn hoangpn force-pushed the feature/permission_check_for_alertmanager branch from 8b0d658 to 0b66070 Compare June 3, 2025 09:33
@hoangpn
Copy link
Contributor Author

hoangpn commented Jun 3, 2025

I've force pushed because I found a misleading new line in test_rest.py 🙇

@hoangpn
Copy link
Contributor Author

hoangpn commented Jun 3, 2025

@vincent-olivert-riera
The PR is ready. Please check it again when you have time. Thank you. 🙇

@vincent-olivert-riera vincent-olivert-riera merged commit 6932526 into line:master Jun 3, 2025
5 checks passed
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.

2 participants