fix(content): enforce anonymous access restrictions for content references endpoints#35509
fix(content): enforce anonymous access restrictions for content references endpoints#35509erickgonzalez wants to merge 1 commit intomainfrom
Conversation
…ences endpoints - Updated `getContentletReferences` and `getAllContentletReferencesCount` to require `AnonymousAccess.NONE`, ensuring unauthenticated callers are blocked. - Added tests to verify that unauthorized (anonymous) requests throw `SecurityException` as expected, mapping to HTTP 401 responses. - Enhanced OpenAPI documentation, adding `403 Forbidden` responses to describe cases where users lack contentlet read permissions. - Refactored `createAnonymousRequest` utility for better test coverage. ref: #30584 Signed-off-by: erickgonzalez <[email protected]>
|
Claude finished @erickgonzalez's task in 2m 10s —— View job PR Review
The security change itself is correct and straightforward. A few things worth a second look: Tests create content that is never reached
// current — unnecessary DB work
final Structure structure = new StructureDataGen().nextPersisted();
final Contentlet content = new ContentletDataGen(structure.getInode())
.languageId(english.getId()).nextPersisted();
new ContentResource().getContentletReferences(
createAnonymousRequest(), mock(HttpServletResponse.class),
content.getIdentifier(), "");
// simpler
new ContentResource().getContentletReferences(
createAnonymousRequest(), mock(HttpServletResponse.class),
"non-existent-id", "");
if (builder.anonAccess == AnonymousAccess.NONE || AnonymousAccess.systemSetting() == AnonymousAccess.NONE)So when the endpoint specifies
The YAML gets a 403 for Overall: the core security fix ( |
getContentletReferencesandgetAllContentletReferencesCountto requireAnonymousAccess.NONE, ensuring unauthenticated callers are blocked.SecurityExceptionas expected, mapping to HTTP 401 responses.403 Forbiddenresponses to describe cases where users lack contentlet read permissions.createAnonymousRequestutility for better test coverage.ref: #30584