Repository navigation
Require the publishable permission to write CWA content (#569) - #579
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #579 +/- ##
=========================================
Coverage 97.05% 97.06%
- Complexity 5302 5318 +16
=========================================
Files 433 434 +1
Lines 13724 13755 +31
=========================================
+ Hits 13320 13351 +31
Misses 404 404
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #569.
Once a non-admin could sign in, they could write CWA content straight through the API. The only guard was the template's catch-all
IS_AUTHENTICATED_FULLYaccess rule.What changes
ContentWriteSecurityResourceMetadataCollectionFactory, at decoration priority -1. That makes it the outermost bundle factory, so it also sees the operations the other factories add (/move, uploads). It gives everyPOST/PUT/PATCH/DELETEoperation ofPage,Layout,Route,ComponentGroup,ComponentGroupOrder(the order PATCH),ComponentPosition, and everyAbstractComponentandAbstractPageDatasubclass (project classes included) thesecuritypublishable.permission. When a class sets its own#[Publishable(isGranted:)], that is used instead, resolved the same wayPublishableStatusCheckerdoes it.security, notsecurityPostDenormalize. The expression needs no object, the same wayPublishableStatusCheckerevaluates it.securityis ANDed with the permission. It is not left alone.Route's PATCH/PUT/DELETE carryread_route, andRoutableResourceMetadataCollectionFactorygives page and page data writesread_routable. Both are read checks, and both used to let any reader write. If an operation's own security had counted as an opt-out, those writes would have stayed open. Both checks, androutable_securityon POST, keep applying.extraProperties: [ContentWriteSecurityResourceMetadataCollectionFactory::OPT_OUT_EXTRA_PROPERTY => false]('publishable_permission' => false), set on one operation or on#[ApiResource]for the whole resource. Form/submit(POST and the validating PATCH) opts out, so it stays public.Tests
Security\ContentWriteSecurityTest: a ROLE_USER gets 403 on POST/PATCH/DELETE (PUT where the operation exists) for a dummy component, an html content, a page, a route, a layout, a component group, a component position, page data and a form, and on route generation, the order PATCH and/move. Anonymous gets 401. An admin can still create and update components, create pages and reorder groups. Users and anonymous callers can still submit forms.DummyPublishableComponentopts out, so the publishable tests for non-admin writers (and the anonymous POST access rule) still cover that logic.Docs issue: components-web-app/docs#310
🤖 Generated with Claude Code