feat(rest): new readOnly user role.#3242
feat(rest): new readOnly user role.#3242rudra-superrr wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
c2046ed to
d7ef8ad
Compare
|
Made the changes. |
|
Resolve the conflicts and can you please add steps to test this PR in the description. |
There was a problem hiding this comment.
Few more areas to look for
- ProjectPermissions.java — isVisible() needs VIEWER awareness
- ProjectController.java — VIEWER sees full project objects ,needs field stripping
ProjectController.java— Missing VIEWER guards on multiple project endpoints
| Endpoint | Line | What's missing |
|---|---|---|
GET /projects/{id}/licenseClearing |
L457 | default should be blocked — add throwIfReadOnlyUser with a // TODO: revisit after License Clearing decision comment |
GET /projects/{id}/linkedProjects |
L580 | VIEWER must not see linked projects — add throwIfReadOnlyUser |
GET /projects/{id}/linkedProjects/releases |
L629 | Same — add throwIfReadOnlyUser |
-
SW360ReportController.javaL122 — Report exports need per-module VIEWER guardRequirement: "Exports of Excel Sheet are allowed, ReadMeOSS are allowed (from License Clearing Tab), Product Clearing not allowed (from Obligations Tab)."
GET /reportsdispatches to different report types based on amoduleparameter. The requirement says:- ✅ Allowed:
projects,components,licenses(Excel sheets),licenseInfo(ReadMeOSS) - ❌ Blocked:
exportCreateProjectClearingReport(Product Clearing),licenseResourceBundle,projectReleaseSpreadsheetWithEccInfo(ECC) ⚠️ SBOM: needs discussion
Currently there's no VIEWER check at all — every module is accessible.
- ✅ Allowed:
-
SearchController.javaL98 — Search must respect VIEWER restrictionsRequirement: "Search should follow the same restrictions like normal view, Projects with 'Everyone' visibility, all Components & Releases."
GET /searchpasses alltypeMasksto the search service without filtering.For VIEWER this means: components ✅, releases ✅, licenses ✅, projects (EVERYONE only)
⚠️ , vulnerabilities ❌, users ❌. -
"UserController.java" : POST /users/tokens creates API tokens. Currently the EndpointsFilter blocks all POST requests for VIEWER . This means VIEWER cannot create any token — including READ tokens, which the requirement explicitly allows.
Additionally, even if the POST were allowed, there's no check preventing VIEWER from requesting WRITE authorities in the token body. The authorities field in the request is user-supplied. -
In PermissionUtils.java, DEFAULT_USER_GROUP = UserGroup.USER. Per R8, new org-wide users should default to VIEWER. This needs to change to UserGroup.VIEWER
-
Keycloak integration — not present
VIEWER group in Keycloak realm
Sw360UserStorageProviderFactory update to assign VIEWER by default
Department-based USER promotion (configurable via orgmapping.properties from PR #3594)
...nd/vulnerabilities/src/main/java/org/eclipse/sw360/vulnerabilities/VulnerabilityHandler.java
Outdated
Show resolved
Hide resolved
...ies/datahandler/src/main/java/org/eclipse/sw360/datahandler/permissions/PermissionUtils.java
Outdated
Show resolved
Hide resolved
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
...ource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/filter/EndpointsFilter.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/eclipse/sw360/rest/resourceserver/vulnerability/VulnerabilityController.java
Show resolved
Hide resolved
01a6f72 to
7b66ca9
Compare
GMishx
left a comment
There was a problem hiding this comment.
I guess only one miss-understanding happened here. Rest looks good.
...ce-server/src/main/java/org/eclipse/sw360/rest/resourceserver/project/ProjectController.java
Outdated
Show resolved
Hide resolved
|
A quick question, you'd be implementing the changes for KeyCloak in this branch or in a separate PR? I'd prefer a separate PR to keep it logically separated as well. |
7b66ca9 to
0009780
Compare
GMishx
left a comment
There was a problem hiding this comment.
Final few changes still needed
| ) throws TException, URISyntaxException, PaginationParameterException, ResourceClassNotFoundException { | ||
|
|
||
| User sw360User = restControllerHelper.getSw360UserFromAuthentication(); | ||
| restControllerHelper.throwIfViewerUser(sw360User); // VIEWER must not see linked projects |
There was a problem hiding this comment.
This would still have to be removed?
There was a problem hiding this comment.
Please block following endpoints for viewer role as well:
- /vulnerabilitySummary
- /vulnerabilities
f3f0a6a to
c6065ea
Compare
Implement read-only VIEWER role (UserGroup.VIEWER) with restricted access across REST API endpoints: - Block VIEWER from vulnerabilities, obligations, ECC, reports, clearing/moderation requests, and Fossology operations - Restrict project visibility to EVERYONE for VIEWER users - Block mutation operations (POST/PATCH/PUT/DELETE) in EndpointsFilter - Allow VIEWER to create READ-only API tokens - Strip non-permitted fields from project responses for VIEWER - Return empty project sets for component/release usedBy queries - Restrict search to allowed types (no vulnerabilities, obligations) - Add PermissionUtils.isViewer() and VIEWER case in role hierarchy - Add VIEWER visibility guard in ProjectPermissions.isVisible() - Add throwIfViewerUser() helper in RestControllerHelper - Add unit and REST integration tests for VIEWER restrictions Signed-off-by: Bibhuti Bhusan Dash <bibhuti230185@gmail.com>
c6065ea to
8c2ed6e
Compare
Issue: #3241
This will restrict the endpoints for the new readOnly user role.