♻️(backend) remove different reach for authenticated and anonymous

If anonymous users have reader access on a parent, we were considering
that an edge use case was interesting: allowing an authenticated user
to still be editor on the child.

Although this use case could be interesting, we consider, as a first
approach, that the value it carries is not big enough to justify the
complexity for the user to understand this complex access right heritage.
This commit is contained in:
Samuel Paccoud - DINUM
2025-07-01 15:13:40 +02:00
committed by Nathan Panchout
parent 55ea7f8375
commit 8c714bfdc6
2 changed files with 7 additions and 10 deletions
+6 -6
View File
@@ -115,16 +115,16 @@ class LinkReachChoices(models.TextChoices):
if LinkRoleChoices.EDITOR in reach_roles.get(cls.PUBLIC, set()):
return {cls.PUBLIC: [LinkRoleChoices.EDITOR]}
# Rule 2: public/reader
if LinkRoleChoices.READER in reach_roles.get(cls.PUBLIC, set()):
result.get(cls.AUTHENTICATED, set()).discard(LinkRoleChoices.READER)
result.pop(cls.RESTRICTED, None)
# Rule 3: authenticated/editor
# Rule 2: authenticated/editor
if LinkRoleChoices.EDITOR in reach_roles.get(cls.AUTHENTICATED, set()):
result[cls.AUTHENTICATED].discard(LinkRoleChoices.READER)
result.pop(cls.RESTRICTED, None)
# Rule 3: public/reader
if LinkRoleChoices.READER in reach_roles.get(cls.PUBLIC, set()):
result.pop(cls.AUTHENTICATED, None)
result.pop(cls.RESTRICTED, None)
# Rule 4: authenticated/reader
if LinkRoleChoices.READER in reach_roles.get(cls.AUTHENTICATED, set()):
result.pop(cls.RESTRICTED, None)
@@ -1190,7 +1190,6 @@ def test_models_documents_restore_complex_bis(django_assert_num_queries):
(
[{"link_reach": "public", "link_role": "reader"}],
{
"authenticated": ["editor"],
"public": ["reader", "editor"],
},
),
@@ -1255,7 +1254,6 @@ def test_models_documents_restore_complex_bis(django_assert_num_queries):
{"link_reach": "public", "link_role": "reader"},
],
{
"authenticated": ["editor"],
"public": ["reader", "editor"],
},
),
@@ -1266,7 +1264,6 @@ def test_models_documents_restore_complex_bis(django_assert_num_queries):
{"link_reach": "public", "link_role": "reader"},
],
{
"authenticated": ["editor"],
"public": ["reader", "editor"],
},
),
@@ -1276,7 +1273,7 @@ def test_models_documents_restore_complex_bis(django_assert_num_queries):
{"link_reach": "authenticated", "link_role": "editor"},
{"link_reach": "public", "link_role": "reader"},
],
{"authenticated": ["editor"], "public": ["reader", "editor"]},
{"public": ["reader", "editor"]},
),
(
[