-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Fixes #14117] Implement the option to configure the default permissions for registered members and add for anonymous default #14122
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
base: master
Are you sure you want to change the base?
Changes from all commits
735d8b9
0ce9cd5
1edac9d
2da05c7
fb533ee
26228e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,9 @@ | |
| from geonode.services.enumerations import CASCADED | ||
| from geonode.security.utils import skip_registered_members_common_group | ||
| from geonode.security.permissions import ( | ||
| get_default_anonymous_compact_permission, | ||
| VIEW_RIGHTS, | ||
| DOWNLOAD_RIGHTS, | ||
| VIEW_PERMISSIONS, | ||
| OWNER_PERMISSIONS, | ||
| DOWNLOAD_PERMISSIONS, | ||
|
|
@@ -244,13 +247,13 @@ def set_permissions( | |
| if not skip_registered_members_common_group(user_group): | ||
| create_geofence_rules(_resource, perms, None, user_group, batch) | ||
| exist_geolimits = exist_geolimits or has_geolimits(_resource, None, user_group) | ||
|
|
||
| # Anonymous | ||
| if settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION: | ||
| anonymous_compact = get_default_anonymous_compact_permission() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this part should not be longer required. Since we have an handler in the permissions_registry, the permissions should be already internally managed without the need to re-write again the check. This is valid also in other parts of the code |
||
| if anonymous_compact in (VIEW_RIGHTS, DOWNLOAD_RIGHTS): | ||
| create_geofence_rules(_resource, VIEW_PERMISSIONS, None, None, batch) | ||
| exist_geolimits = exist_geolimits or has_geolimits(_resource, None, None) | ||
|
|
||
| if settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION: | ||
| if anonymous_compact == DOWNLOAD_RIGHTS: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this part should not be longer required. Since we have an handler in the permissions_registry, the permissions should be already internally managed without the need to re-write again the check. This is valid also in other parts of the code |
||
| create_geofence_rules(_resource, DOWNLOAD_PERMISSIONS, None, None, batch) | ||
| exist_geolimits = exist_geolimits or has_geolimits(_resource, None, None) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,11 @@ | |
| from functools import reduce | ||
|
|
||
| from django.db.models import Q | ||
| from django.conf import settings | ||
| from geonode.security.permissions import ( | ||
| get_default_anonymous_compact_permission, | ||
| VIEW_RIGHTS, | ||
| DOWNLOAD_RIGHTS, | ||
| ) | ||
| from django.contrib.auth import get_user_model | ||
| from django.core.exceptions import ObjectDoesNotExist | ||
| from django.contrib.auth.models import Group, Permission | ||
|
|
@@ -198,7 +202,8 @@ def set_default_permissions(self, owner=None, created=False, **kwargs): | |
| user_groups = Group.objects.filter(name__in=_owner.groupmember_set.values_list("group__slug", flat=True)) | ||
|
|
||
| # Anonymous | ||
| anonymous_can_view = settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION | ||
| anonymous_compact = get_default_anonymous_compact_permission() | ||
| anonymous_can_view = anonymous_compact == VIEW_RIGHTS | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this part should not be longer required. Since we have an handler in the permissions_registry, the permissions should be already internally managed without the need to re-write again the check. This is valid also in other parts of the code |
||
| if anonymous_can_view: | ||
| perm_spec["groups"][anonymous_group] = ["view_resourcebase"] | ||
| else: | ||
|
|
@@ -211,7 +216,7 @@ def set_default_permissions(self, owner=None, created=False, **kwargs): | |
| ): | ||
| perm_spec["groups"][user_group] = ["view_resourcebase"] | ||
|
|
||
| anonymous_can_download = settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION | ||
| anonymous_can_download = anonymous_compact == DOWNLOAD_RIGHTS | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this part should not be longer required. Since we have an handler in the permissions_registry, the permissions should be already internally managed without the need to re-write again the check. This is valid also in other parts of the code |
||
| if anonymous_can_download: | ||
| perm_spec["groups"][anonymous_group] = ["view_resourcebase", "download_resourcebase"] | ||
| else: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.