From 1e3d238c441f54ac4030ab58c8cf54127097d6f8 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:12:34 -0300 Subject: [PATCH] Casts a repo object before checking permission fixes: #5619 (cherry picked from commit 93f241f34c503da0fbac94bdba739feda2636e12) --- CHANGES/5619.bugfix | 2 ++ pulpcore/app/global_access_conditions.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 CHANGES/5619.bugfix diff --git a/CHANGES/5619.bugfix b/CHANGES/5619.bugfix new file mode 100644 index 0000000000..058c075bf6 --- /dev/null +++ b/CHANGES/5619.bugfix @@ -0,0 +1,2 @@ +Fixed a bug in `has_repo_or_repo_ver_param_model_or_obj_perms` function to make +it work with plugin Repositories. diff --git a/pulpcore/app/global_access_conditions.py b/pulpcore/app/global_access_conditions.py index 2a5875fcfb..b19c95317f 100644 --- a/pulpcore/app/global_access_conditions.py +++ b/pulpcore/app/global_access_conditions.py @@ -479,9 +479,9 @@ def has_repo_or_repo_ver_param_model_or_obj_perms(request, view, action, permiss ) serializer.is_valid(raise_exception=True) if repository := serializer.validated_data.get("repository"): - return request.user.has_perm(permission, repository) + return request.user.has_perm(permission, repository.cast()) elif repo_ver := serializer.validated_data.get("repository_version"): - return request.user.has_perm(permission, repo_ver.repository) + return request.user.has_perm(permission, repo_ver.repository.cast()) return True