Skip to content

[Fixes #14117] Implement the option to configure the default permissions for registered members and add for anonymous default#14122

Open
sijandh35 wants to merge 6 commits intomasterfrom
ISSUE_14117
Open

[Fixes #14117] Implement the option to configure the default permissions for registered members and add for anonymous default#14122
sijandh35 wants to merge 6 commits intomasterfrom
ISSUE_14117

Conversation

@sijandh35
Copy link
Copy Markdown
Contributor

Fixes #14117

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

For all pull requests:

  • Confirm you have read the contribution guidelines
  • You have sent a Contribution Licence Agreement (CLA) as necessary (not required for small changes, e.g., fixing typos in the documentation)
  • Make sure the first PR targets the master branch, eventual backports will be managed later. This can be ignored if the PR is fixing an issue that only happens in a specific branch, but not in newer ones.

The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):

  • There is a ticket in https://github.com/GeoNode/geonode/issues describing the issue/improvement/feature (a notable exemption is, changes not visible to end-users)
  • The issue connected to the PR must have Labels and Milestone assigned
  • PR for bug fixes and small new features are presented as a single commit
  • PR title must be in the form "[Fixes #<issue_number>] Title of the PR"
  • New unit tests have been added covering the changes, unless there is an explanation on why the tests are not necessary/implemented

Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.

…ered members and add for annonymous default
@cla-bot cla-bot Bot added the cla-signed CLA Bot: community license agreement signed label Apr 10, 2026
@sijandh35 sijandh35 marked this pull request as draft April 10, 2026 07:09
@sijandh35 sijandh35 marked this pull request as ready for review April 10, 2026 07:09
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a compact permissions system for default groups, deprecating the legacy boolean settings for anonymous view and download permissions. It implements the DEFAULT_ANONYMOUS_PERMISSIONS and DEFAULT_REGISTERED_MEMBERS_PERMISSIONS settings and adds a new DefaultSpecialGroupsPermissionsHandler to automate permission assignment during resource creation. The changes span security handlers, models, and the Geoserver manager to ensure integration and backward compatibility, supported by new unit tests. I have no feedback to provide.

@giohappy giohappy changed the title [Fixes #14117] Fixes option to configure the default permissions for registered members and add for annonymous default [Fixes #14117] Fixes option to configure the default permissions for registered members and add for anonymous default Apr 10, 2026
@giohappy giohappy changed the title [Fixes #14117] Fixes option to configure the default permissions for registered members and add for anonymous default [Fixes #14117] Implement the option to configure the default permissions for registered members and add for anonymous default Apr 10, 2026
@giohappy giohappy closed this Apr 13, 2026
@giohappy giohappy reopened this Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 85.24590% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.58%. Comparing base (0e26b31) to head (26228e1).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14122      +/-   ##
==========================================
+ Coverage   74.55%   74.58%   +0.03%     
==========================================
  Files         958      958              
  Lines       58043    58151     +108     
  Branches     7920     7934      +14     
==========================================
+ Hits        43276    43374      +98     
- Misses      13000    13005       +5     
- Partials     1767     1772       +5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread geonode/settings.py
# - DEFAULT_ANONYMOUS_PERMISSIONS: view | download | none
# - DEFAULT_REGISTERED_MEMBERS_PERMISSIONS: view | download | edit | manage | none
DEFAULT_ANONYMOUS_PERMISSIONS = os.getenv("DEFAULT_ANONYMOUS_PERMISSIONS", None)
DEFAULT_REGISTERED_MEMBERS_PERMISSIONS = os.getenv("DEFAULT_REGISTERED_MEMBERS_PERMISSIONS", None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If those two variables are the new default, i think the default value should not be None, but what we want to be the new default like download


# Anonymous
if settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION:
anonymous_compact = get_default_anonymous_compact_permission()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

exist_geolimits = exist_geolimits or has_geolimits(_resource, None, None)

if settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION:
if anonymous_compact == DOWNLOAD_RIGHTS:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

# Anonymous
anonymous_can_view = settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION
anonymous_compact = get_default_anonymous_compact_permission()
anonymous_can_view = anonymous_compact == VIEW_RIGHTS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

perm_spec["groups"][user_group] = ["view_resourcebase"]

anonymous_can_download = settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION
anonymous_can_download = anonymous_compact == DOWNLOAD_RIGHTS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Comment thread geonode/security/utils.py
@staticmethod
def is_anonymous_can_view():
return settings.DEFAULT_ANONYMOUS_VIEW_PERMISSION
return get_default_anonymous_compact_permission() in (VIEW_RIGHTS, DOWNLOAD_RIGHTS)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here we should use the permissions registry? the permisisons for anonymous should be mananaged already there

Comment thread geonode/security/utils.py
@staticmethod
def is_anonymous_can_download():
return settings.DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION
return get_default_anonymous_compact_permission() == DOWNLOAD_RIGHTS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here we should use the permissions registry? the permisisons for anonymous should be mananaged already there

Comment thread geonode/context_processors.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed CLA Bot: community license agreement signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the option to configure the default permissions for registered members in GeoNode

3 participants