From 65718a149ff9d88d23e659685da2db79940f0131 Mon Sep 17 00:00:00 2001 From: Andrii V Date: Mon, 26 May 2025 21:22:45 +0200 Subject: [PATCH 1/2] fix: RCCE-247 branch permissions with user groups --- rhodecode/lib/auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py index 94661097..1029f879 100644 --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -413,7 +413,7 @@ class BranchPermOriginDict(dict): else: (pattern_perm, origin) = pattern_perm_origin - # we're passing in the dict, so we save the the stack + # we're passing in the dict, so we save the stack for pattern, perm in list(pattern_perm.items()): self.perm_origin_stack.setdefault(key, {}).setdefault(pattern, []).append((perm, origin)) @@ -849,7 +849,8 @@ class PermissionCalculator(object): multiple_counter[r_k] += 1 if multiple_counter[r_k] > 1: - cur_perm = self.permissions_repository_branches[r_k][pattern] + cur_perm = self.permissions_repository_branches.perm_origin_stack[r_k][pattern] + cur_perm = cur_perm[0][0] if cur_perm else "branch.none" p = self._choose_permission(p, cur_perm) self.permissions_repository_branches[r_k] = {pattern: p}, o From 44f1ac281c7d08a0936ea6cc4af6f04da877b59a Mon Sep 17 00:00:00 2001 From: Andrii V Date: Wed, 18 Jun 2025 15:58:51 +0200 Subject: [PATCH 2/2] fix: permission groups - refactored a bit --- rhodecode/lib/auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py index 1029f879..8a05972a 100644 --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -849,8 +849,9 @@ class PermissionCalculator(object): multiple_counter[r_k] += 1 if multiple_counter[r_k] > 1: - cur_perm = self.permissions_repository_branches.perm_origin_stack[r_k][pattern] - cur_perm = cur_perm[0][0] if cur_perm else "branch.none" + # Get the previous permission for this pattern, with fallback, from perm_origin_stack that keeps history + pattern_perms = self.permissions_repository_branches.perm_origin_stack.get(r_k, {}).get(pattern, []) + cur_perm = pattern_perms[0][0] if pattern_perms else "branch.none" p = self._choose_permission(p, cur_perm) self.permissions_repository_branches[r_k] = {pattern: p}, o