Skip to content

Restrict user and user group management API to administrators - #220

Merged
SteRiccio merged 14 commits into
masterfrom
fix/api-auth-users-groups
Nov 10, 2026
Merged

SteRiccio merged 14 commits into
masterfrom
fix/api-auth-users-groups

Conversation

@SteRiccio

Copy link
Copy Markdown
Member

Method security is not enabled (<global-method-security> is commented out), so @Secured annotations had no effect and any logged user could use the user and user group management API.

  • New AccessControl bean: checks on the user logged in the session, throws AccessDeniedException (403).
  • Users API: create/update/duplicate/delete require ADMIN; reading a user requires ADMIN or the user themselves. Password change of the logged user is unchanged (old password verified).
  • User groups API: create/update/delete and resource association require ADMIN; reading a group requires ADMIN or being related to it (same list the UI shows).
  • /uploadLogo.htm requires ADMIN (the existing rule protected /logoUpload, a different path).
  • The unauthenticated access to /api/** from 127.0.0.1 now applies only in development mode.

Test: AccessControlTest.

Users and user groups can be created, changed or deleted only by admins
(as in the UI); users can still change their own password through
changepassword. Users can read only themselves and their related groups.
The 127.0.0.1 bypass on /api/** now applies only in development mode,
and logo upload requires the admin role.
Survey, record, command, record file, backup/restore and geo endpoints now
check that the logged user can access the survey (survey user group
member or admin) and has the permissions the UI requires for the
operation (same rules as frontend User.js, ported to
RecordAccessControlManager). Record summaries are filtered by the logged
user instead of a client-supplied user. Backup/restore is admin only and
remote restore is refused when no restore key is configured.
/api/datacleansing requires the CLEANSING role.
@SteRiccio SteRiccio self-assigned this Nov 10, 2026
…cords

# Conflicts:
#	collect-server/src/main/java/org/openforis/collect/web/controller/CommandController.java
…cords

Use constructor injection for AccessControl in all controllers (the
merged branch introduced it for AccessControl and the user controllers)
and fix the Sonar test issues (@mock fields, single invocation in
assertThrows lambdas).
Check survey and record access in data and survey API
@sonarqubecloud

Copy link
Copy Markdown

@SteRiccio
SteRiccio merged commit 4ac9a6e into master Nov 10, 2026
3 checks passed
@SteRiccio
SteRiccio deleted the fix/api-auth-users-groups branch November 10, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant