-
Notifications
You must be signed in to change notification settings - Fork 480
Rest api to reset permissions for an asset [#33914] #33915
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: main
Are you sure you want to change the base?
Rest api to reset permissions for an asset [#33914] #33915
Conversation
1. New GET /permissions/{assetId} endpoint - View asset permissions with pagination, supporting all permissionable types (folders, hosts, contentlets, etc.)
2. Permission helper infrastructure - Added AssetPermissionHelper for building responses and ResponseEntityAssetPermissionsView for typed API responses, integrated via CDI
3. Documentation and tests - OpenAPI spec updates and comprehensive Postman test suite covering happy paths, pagination, validation, and error cases
…-api-to-update-asset-permissions
- PUT /api/v1/permissions/{assetId} - REST endpoint to save/update asset permissions (admin-only)
- Auto-breaks inheritance when saving on inheriting asset, supports ?cascade=true for async propagation
- Returns message, permissionCount, inheritanceBroken, and updated asset object
- Reset API: PUT /api/v1/permissions/{assetId}/_reset removes individual permissions, making asset inherit from parent
- Idempotency: Returns 409 Conflict if asset already inherits; includes previousPermissionCount in response
- Admin-only: Restricted to admin users for safety
…-get-asset-permissions
- fix constructor calls
…-get-asset-permissions
- use immutables for views - use established paginator pattern to return paginated results - refactor assetPermissionHelper and return typed views.
…o-update-asset-permissions
- integration tests added for PUT /permissions/{assetId} - basic update, validation errors, inheritance breaking, security checks
- Pattern alignment - forms extend Validated with checkValid(), typed immutable response views, OpenAPI spec updates
- refactor and use permissionUtils and enums where applicable. - fix integration tests.
…-get-asset-permissions
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled with no activity. |
…o-update-asset-permissions
…rest-api-to-reset-permissions-for-an-asset
- Refactored reset permissions endpoint to use typed @Value.Immutable view class instead of Map<String, Object>, matching the pattern used by updateAssetPermissions.
…-api-to-update-asset-permissions
…s for type-safe permission handling
…rest-api-to-reset-permissions-for-an-asset
| "request": { | ||
| "auth": { | ||
| "type": "basic", | ||
| "basic": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of our collections configure authentication at the collection level. This prevents you from having to repeat the auth settings for every individual request.
You can check PagesResourceTests.json for a reference on how this is structured:
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{jwt}}",
"type": "string"
}
]
},Note that you will likely also need a Pre-request Script at the collection level to generate and assign the {{jwt}} variable.
| } catch (Exception e) { | ||
| Logger.warn(this, String.format( | ||
| "Failed to trigger cascade for role %s: %s", | ||
| roleForm.getRoleId(), e.getMessage())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the method failed to cascade permissions, we need to call a method similar to buildUpdateResponse and set an error message indicating so.
|
|
||
| // Verify user is admin | ||
| if (!user.isAdmin()) { | ||
| Logger.warn(this, String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not being an admin throws an exception, this should be Logger.error
|
|
||
| // Verify user is admin | ||
| if (!user.isAdmin()) { | ||
| Logger.warn(this, String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not being an admin throws an exception, this should be Logger.error
| // Note: With enum types, null values may be filtered by Jackson or cause | ||
| // NullPointerException during bit conversion. The test validates the form | ||
| // handles this gracefully. | ||
| } catch (BadRequestException | NullPointerException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it expect a NullPointer or a BadRequest exception? I don't see how the expected output might be different if we always use the same test with the same input and the Jackson version is always the same
Proposed Changes
Checklist
Additional Info
** any additional useful context or info **
Screenshots
This PR fixes: #33914