Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception in in-memory permission backend (fixes #2687) #3493

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions kinto/core/permission/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def get_accessible_objects(self, principals, bound_permissions=None, with_childr
candidates = []
if bound_permissions is None:
for key, value in self._store.items():
_, object_id, permission = key.split(":", 2)
candidates.append((object_id, permission, value))
if key.startswith("permission:"):
_, object_id, permission = key.split(":", 2)
candidates.append((object_id, permission, value))
else:
for pattern, perm in bound_permissions:
id_match = ".*" if with_children else "[^/]+"
Expand Down
6 changes: 6 additions & 0 deletions kinto/core/permission/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ def test_accessible_objects_without_match(self):
)
self.assertEqual(sorted(per_object_ids.keys()), ["/url/a", "/url/a/id/1", "/url/a/id/2"])

def test_accessible_objects_with_user_principle(self):
self.permission.add_user_principal("user1", "group")
self.permission.add_principal_to_ace("id1", "write", "user1")
per_object_ids = self.permission.get_accessible_objects(["user1"])
self.assertEqual(sorted(per_object_ids.keys()), ["id1"])

#
# get_object_permissions()
#
Expand Down
Loading