Skip to content

Add Object permissions to project and allow set add_check globally or per-project - #653

Open
mchehab wants to merge 6 commits into
getpatchwork:mainfrom
mchehab:object-permissions
Open

Add Object permissions to project and allow set add_check globally or per-project#653
mchehab wants to merge 6 commits into
getpatchwork:mainfrom
mchehab:object-permissions

Conversation

@mchehab

@mchehabmchehab commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Currently, patchwork doesn't allow granting permissions to add_checks without promoting an user to superuser.

This patch series:

  • add a button at project admin, allowing to select per-project add_check permissions;
  • change the logic which accepts adding check to use either a global add_check permission or per project, per-user permission;
  • now, having a maintainer status is orthogonal to add CI checks: maintainers that need to also update CI need to be granted with CI add checks permission.

@stephenfin

Copy link
Copy Markdown
Member

@mchehab Could you propose these against the main branch and I'll backport them myself?

@mchehab
mchehabforce-pushed the object-permissions branch from b99ac5a to 054de50CompareJune 7, 2026 15:59
@mchehab

Copy link
Copy Markdown
ContributorAuthor

@mchehab Could you propose these against the main branch and I'll backport them myself?

Done. I'll keept django-guardian~=3.3.1 dependency, but feel free to use a newer one if you prefer.
I will dropped one patch (4e3d25d), which is not seem to be doing any difference.

@stephenfin
stephenfin changed the base branch from stable/3.2 to mainJune 7, 2026 16:02
@mchehab

mchehab commented Jun 7, 2026

Copy link
Copy Markdown
ContributorAuthor

Thanks for changing the baseline. My user were unable to change the baseline indication at the PR.

@mchehab

mchehab commented Jun 7, 2026

Copy link
Copy Markdown
ContributorAuthor

hmm... this one requires more work... it actually added "add <project>" instead of "add <checks>"

@mchehabmchehab changed the title Object permissions[RFC] Object permissionsJun 7, 2026
@mchehab

Copy link
Copy Markdown
ContributorAuthor

I changed this one to RFC, as some work is still needed to be able to have per-project permissions.

@mchehab

mchehab commented Jun 7, 2026

Copy link
Copy Markdown
ContributorAuthor

Ah, the patch I dropped made some difference (or perhaps a re-run on manage.py migrate).

It is now shown:
image

so, besides add/change/delete/view project, there is an "add checks" over there.

@mchehab

Copy link
Copy Markdown
ContributorAuthor

Tests with https://github.com/mchehab/pw_tools:

User without global "add_check" permission:

$ ./pw-checks.py -p local set 20260606114703.5-1-ruoyuw560@gmail.com foo warning "" "No link"
ERROR: 147247: foo failed to set 'warning': 403 Client Error: Forbidden for url: http://127.0.0.1:8000/api/patches/147247/checks/

After granting patchwork | checks | add_check at Users admin:

$ ./pw-checks.py -p local set 20260606114703.5-1-ruoyuw560@gmail.com foo1 warning "" "No link"
INFO: 147247: foo1 set to 'warning'

After removing patchwork | checks | add_check at Users admin:

$ ./pw-checks.py -p local set 20260606114703.5-1-ruoyuw560@gmail.com foo4 warning "" "No link"
ERROR: 147247: foo4 failed to set 'warning': 403 Client Error: Forbidden for url: http://127.0.0.1:8000/api/patches/147247/checks/

After granding Projects -> <project_name> -> <Object permissions>add_check permission:

 $ ./pw-checks.py -p local set 20260606114703.5-1-ruoyuw560@gmail.com foo4 warning "" "No link"
INFO: 147247: foo4 set to 'warning'

In summary, both coarse grained and fine grained add_check permission worked.

@mchehabmchehab changed the title [RFC] Object permissionsAdd Object permissions to project and allow set add_check globally or per-projectJun 7, 2026

@matttbematttbe left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for looking at this! I have a couple of questions/ suggestions of you don't mind.

Comment threadpatchwork/api/check.py
Comment threadrequirements-dev.txt
Comment threadpatchwork/api/check.py Outdated
mchehaband others added 6 commits June 24, 2026 14:40
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Removing this grant will be disruptive, so, for now, keep it
enabled for maintainers.
A better approach would be to handle it at migration time.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
@mchehab
mchehabforce-pushed the object-permissions branch from e331e0f to 33ce208CompareJune 24, 2026 12:53
Sign up for freeto 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.

3 participants

@mchehab@stephenfin@matttbe