Permitted roles for restricted pages - #4112
Open
sascha-karnatz wants to merge 5 commits into
Open
Conversation
This was referenced Jul 29, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4112 +/- ##
=======================================
Coverage 98.27% 98.28%
=======================================
Files 351 352 +1
Lines 9224 9247 +23
=======================================
+ Hits 9065 9088 +23
Misses 159 159 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tvdeyen
reviewed
Jul 29, 2026
sascha-karnatz
force-pushed
the
permitted-roles-for-restricted-pages
branch
from
July 30, 2026 07:49
f87322a to
89fe4b0
Compare
sascha-karnatz
added a commit
to AlchemyCMS/alchemy_i18n
that referenced
this pull request
Jul 30, 2026
These translations all translated by Claude Opus 5. Ref: AlchemyCMS/alchemy_cms#4112
sascha-karnatz
force-pushed
the
permitted-roles-for-restricted-pages
branch
from
August 4, 2026 07:34
89fe4b0 to
db959bc
Compare
sascha-karnatz
changed the base branch from
main
to
conditional-field-component
August 4, 2026 07:36
Add a new permitted_roles column with a space separated list of roles, that can access a page. The default values is "member" to support the same behavior as before.
...to test that feature better in the dummy app.
Add getter and setter to the page model to split and join the group collection. Extend the set_restrictions_to_child_pages behavior to update permitted_roles as well. It was necessary to move from before_save to after_save to update restricted and permitted_roles of child pages. Otherwise inherit_restricted_status would read old data from the database.
Test if the user has the correct role to read the page. This change only affects the MemberUser permission. GuestUser can't see restricted pages and AuthorUser includes the MemberUser module. If Alchemy will be extended by other roles (like restricted_test in the Dummy app), it is necessary to create new abilities to prevent misconfigurations (like to many redirects).
Provide a new PagePermittedRolesSelect view component to render a select with all configured permitted_roles. The select is only visible if the restricted checkbox is enabled. Remove the width for the input-column class. Without the width this class can also be used for the PagePermittedRolesSelect and the missing width does not have a visual difference in all other place where the class is used (ElementScheduleTimestamps and PagePublicationFields).
tvdeyen
force-pushed
the
permitted-roles-for-restricted-pages
branch
from
August 4, 2026 08:06
db959bc to
cc39279
Compare
tvdeyen
reviewed
Aug 4, 2026
tvdeyen
left a comment
Member
There was a problem hiding this comment.
I think we need to adjust the permission to use a scope as well. There are likely more places that we need to check
| @@ -70,7 +70,7 @@ def alchemy_member_rules | |||
| end | |||
|
|
|||
| can :read, Alchemy::Page, Alchemy::Page.published.from_current_site do |p| | |||
Member
There was a problem hiding this comment.
Do we need a scope here as well in order to get the correct collection of pages by Alchemy::Page.accessible_by(current_ability)? We use that in
and probably other places. Can we add a spec to confirm?
| p.public? && p.site == Alchemy::Current.site && p.readable_by?(@user) | ||
| end | ||
|
|
||
| can :read, Alchemy::Node, Alchemy::Node.available_to_members do |node| |
Member
There was a problem hiding this comment.
We probably need to adjust the Alchemy::Node.available_to_members scope as well.
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.
Note
There was a previous PR #4102 that used
restricted_rolesinstead ofpermitted_rolesas column.What is this pull request for?
Add a
permitted_rolescolumn to the Page model to extend the restricted page behavior. This way it is possible restrict the access to pages only for a smaller set of users with a given role.Notable changes (remove if none)
There is an addition to the MemberUser permission that is now evaluating also the
permitted_rolescolumn on the page. The default value is "member" and it should behave same way as before.Screenshots
Checklist