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

[Fixes #11995 Implement POST and PATCH methods for the User API #12011

Merged
merged 11 commits into from
Mar 7, 2024

Conversation

mattiagiupponi
Copy link
Contributor

@mattiagiupponi mattiagiupponi commented Mar 1, 2024

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
  • Commit message must be in the form "[Fixes #<issue_number>] Title of the Issue"
  • New unit tests have been added covering the changes, unless there is an explanation on why the tests are not necessary/implemented
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • This PR passes the QA checks: black geonode && flake8 geonode
  • Commits changing the settings, UI, existing user workflows, or adding new functionality, need to include documentation updates
  • Commits adding new texts do use gettext and have updated .po / .mo files (without location infos)

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.

@cla-bot cla-bot bot added the cla-signed CLA Bot: community license agreement signed label Mar 1, 2024
Copy link

gitguardian bot commented Mar 1, 2024

⚠️ GitGuardian has uncovered 7 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9702486 Triggered Generic Password 4bad53a geonode/people/tests.py View secret
9702486 Triggered Generic Password ee071e2 geonode/people/tests.py View secret
9702486 Triggered Generic Password 26c940f geonode/people/tests.py View secret
9702487 Triggered Username Password 4bad53a geonode/people/tests.py View secret
9702487 Triggered Username Password 26c940f geonode/people/tests.py View secret
9705160 Triggered Username Password c0c4dfb geonode/base/api/tests.py View secret
9768717 Triggered Username Password ee071e2 geonode/people/tests.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Merging #12011 (26c940f) into ISSUE_11995 (023761d) will increase coverage by 0.13%.
The diff coverage is 99.46%.

Additional details and impacted files
@@               Coverage Diff               @@
##           ISSUE_11995   #12011      +/-   ##
===============================================
+ Coverage        63.67%   63.81%   +0.13%     
===============================================
  Files              867      867              
  Lines            52664    52843     +179     
  Branches          6600     6609       +9     
===============================================
+ Hits             33535    33720     +185     
+ Misses           17610    17598      -12     
- Partials          1519     1525       +6     

geonode/people/views.py Outdated Show resolved Hide resolved
geonode/people/views.py Outdated Show resolved Hide resolved
geonode/people/views.py Outdated Show resolved Hide resolved
@@ -139,6 +140,11 @@ def has_object_permission(self, request, view, obj):
elif hasattr(obj, "user"):
_request_matches = obj.user == request.user

if isinstance(obj, get_user_model()) and not request.user.is_anonymous:
if request.method in permissions.SAFE_METHODS and obj in get_available_users(request.user):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a good way to re-use the already existing IsOwnerOrAdmin we decided to use this class, because the check on the User object was already present. We just update the check to be sure that the users that belong to the same group can see each other

geonode/people/tests.py Outdated Show resolved Hide resolved
geonode/people/tests.py Outdated Show resolved Hide resolved
geonode/people/views.py Show resolved Hide resolved
geonode/people/views.py Outdated Show resolved Hide resolved
@mattiagiupponi mattiagiupponi added this to the 4.3.0 milestone Mar 7, 2024
@mattiagiupponi mattiagiupponi merged commit a411232 into ISSUE_11995 Mar 7, 2024
12 checks passed
@mattiagiupponi mattiagiupponi deleted the ISSUE_11995_1 branch March 7, 2024 09:34
giohappy added a commit that referenced this pull request Mar 21, 2024
…2072)

* [Fixes #11995 Implement POST and PATCH methods for the User API (#12011)

* [Fixes #11995] Implement POST and PATCH methods for the User API
* Upgrare Remote Docker for CircleCI
* [Fixes #11995] Implement POST and PATCH methods for the User API, refactored validation in serializer

---------

Co-authored-by: RegisSinjari <[email protected]>
Co-authored-by: Giovanni Allegri <[email protected]>

* [Fixes #11995] Implement the DELETE method for the User API (#12028)

* [Fixes #11995] Implement the DELETE method for the User API

* [Fixes #11995] Implement the DELETE method for the User API refactor and docstrings added

* [Fixes #11995] Implement endpoint to transfer resources (#12067)

* [Fixes #11995] Implement endpoint to transfer ownership

* [Issue 11995] Implement endpoint to unregister as a project manager (#12066)

* [FIXES #11995] Implement endpoint to unregister as a project manager

* [FIXES #11995] Implement endpoint to unregister as a project managergroup.group_id

* [FIXES #11995] Implement endpoint to unregister as a project manager,tests added

* [Fixes #11995] black reformatting

* [Fixes #11995] GNIP 99: Implement a CRUD REST API for users

* [Fixes #11995] GNIP 99: Implement a CRUD REST API for users

* Update views.py

---------

Co-authored-by: RegisSinjari <[email protected]>
Co-authored-by: Giovanni Allegri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API v2 cla-signed CLA Bot: community license agreement signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants