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
Discussion options

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

Comment options

You must be logged in to vote
2 replies
@mandrasch
Comment options

@afonic
Comment options

Comment options

You must be logged in to vote
2 replies
@mandrasch
Comment options

@mandrasch
Comment options

Comment options

You must be logged in to vote
3 replies
@mandrasch
Comment options

@afonic
Comment options

@mandrasch
Comment options

Comment options

You must be logged in to vote
2 replies
@mandrasch
Comment options

@aaronbushnell
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
2 replies
@duncanmcclean
Comment options

@cedric-nxstar
Comment options

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