Skip to content

Implement a config option like "allowAdminChanges" - override permissions dynamically based on APP_ENV? #6289

Answered by aaronbushnell
mandrasch asked this question in Q&A

You must be logged in to vote

For what it's worth, I ended up utilizing the same model that this wonderful repo did—shoutout to @justbetter!

Here's the basics of what I'm doing:

  • I'm looking to see if an ALLOW_ADMIN_CHANGES environment variable is set to false
  • If it's true then nothing happens. But if it's false I take the next steps because all users should have reduced permissions.
  • I use $this->app->bind() to bind a custom User class I built to the Statamic\Auth\File\User class (what @afonic suggested)
  • I change the isSuper() method to always return false
  • I change the hasPermission($permission) method to return false when select permissions are requested (configure forms, manage preferences, edit header nav, etc)

It…

Replies: 7 comments 11 replies

You must be logged in to vote
2 replies
@mandrasch

@afonic

You must be logged in to vote
2 replies
@mandrasch

@mandrasch

You must be logged in to vote
3 replies
@mandrasch

@afonic

@mandrasch

You must be logged in to vote
2 replies
@mandrasch

@aaronbushnell

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies
Answer selected by mandrasch

You must be logged in to vote
2 replies
@duncanmcclean

@cedric-nxstar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants