Skip to content

[6.x] Update authorization / permissions #11516

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

Merged
merged 29 commits into from
Mar 13, 2025
Merged

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Feb 28, 2025

This pull request:

  • Only applies our auth logic to Statamic permissions, which prevents us from interfering with custom auth gates.
  • Moves our auth logic from Gate::before to after, enabling users to more easily deny access to things.
  • Adds super user checks to before in most Statamic policies to continue to avoid overhead when users are super.

Closes #8337.
Closes #10832.

Otherwise, when the `Authorize` middleware checks if the user has access to the CP, `Permission:all()` in the `Gate::before()` closure won't return any permissions as they haven't been booted yet.
Until I figure out a better solution. 🤔
Since there's no `DroidsClass` policy, I've updated this test to authorize using a permission instead, which'll work.
@duncanmcclean duncanmcclean marked this pull request as ready for review March 6, 2025 15:25
@duncanmcclean duncanmcclean force-pushed the super-user-authorization branch from 1136551 to 88e702f Compare March 7, 2025 12:46
@duncanmcclean duncanmcclean requested a review from jasonvarga March 7, 2025 16:13
Since more stuff gets evaluated now (all the permissions are compiled) all the sites will be looped over. Many tests were setting up sites without explicit names. They don't really need them so here the site name will fall back to the handle.
@jasonvarga
Copy link
Member

Since we're checking whether an ability is a Statamic one, I had to add a way to get all the resolved permissions. The Permission::all() you had there wouldn't work since it would include placeholders. e.g. edit {collection} entries. The ability passed would be edit blog entries. Permission::flattened() will now resolve all of them.

@jasonvarga jasonvarga changed the title [6.x] Re-work super user authorization check [6.x] Update authorization / permissions Mar 13, 2025
@jasonvarga jasonvarga merged commit a8726dd into master Mar 13, 2025
19 checks passed
@jasonvarga jasonvarga deleted the super-user-authorization branch March 13, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants