From 693113b0b51257b17cda288b2e43a0f3f9459851 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 11 2022 05:20:51 +0000 Subject: [PATCH 1/2] Allow admin group members to set monitoring status Previously, antiya_patch_endpoint only allowed admin users to set the monitoring status. This ensure that members of admin groups are also resolved and allowed to do so. Fixes: https://pagure.io/pagure-dist-git/issue/152 Fixes: https://pagure.io/fedora-infrastructure/issue/10824 --- diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index 43dd6b6..4deacd6 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -58,15 +58,11 @@ def anitya_patch_endpoint(namespace, repo): _check_token(repo, project_token=False) is_site_admin = pagure.utils.is_admin() - admins = [u.username for u in repo.get_project_users("admin")] # Only allow the main admin, the admins of the project, and Pagure site # admins to modify projects' monitoring, even if the user has the right # ACLs on their token - if ( - flask.g.fas_user.username not in admins - and flask.g.fas_user.username != repo.user.username - and not is_site_admin - ): + if (pagure.utils.is_repo_admin(repo, flask.g.fas_user.username) and not + is_site_admin): raise pagure.exceptions.APIError( 401, error_code=APIERROR.EMODIFYPROJECTNOTALLOWED ) From 389f237ddab7cfe687c897bc0f2d7a179a99c273 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 11 2022 05:21:03 +0000 Subject: [PATCH 2/2] Allow all repo admins to override Bugzilla assignee This allows all repo admins and members of repo admin groups to override the Bugzilla assignee. This is a change in the previous behavior, but many users agree that this is how it should behave. Fixes: https://pagure.io/pagure-dist-git/issue/153 --- diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index 4deacd6..c7aace0 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -690,9 +690,10 @@ def bzoverride_patch_endpoint(repo, namespace): repo = _get_repo(repo, namespace=namespace) is_site_admin = pagure.utils.is_admin() - # Only allow the main admin and Pagure site admins to modify projects' + # Only allow project admins and Pagure site admins to modify projects' # monitoring, even if the user has the right ACLs on their token - if flask.g.fas_user.username != repo.user.username and not is_site_admin: + if (not pagure.utils.is_repo_admin(repo, flask.g.fas_user.username) and not + is_site_admin): raise pagure.exceptions.APIError( 401, error_code=APIERROR.EMODIFYPROJECTNOTALLOWED )