-
-
Notifications
You must be signed in to change notification settings - Fork 61
Solution to secure admin-only resources #835
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
Conversation
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
Collaborator
|
I think someday we should have two levels of admin, but agree this should be the path until then |
Collaborator
|
Support removing NON-RESTful actions! |
9dec763 to
434e8c8
Compare
18 tasks
Sets up AdminController to become a base class for admin-only controllers that don't need the sophistication of pundit. Note that we need to disable pundit because it would otherwise try to verify that authorize... was called. See subsequent commit for usage and specs.
434e8c8 to
36d7647
Compare
Collaborator
Author
|
Ready for review. H/T @h-m-m for his help simplifying the auth implementation 🍠 . |
solebared
added a commit
that referenced
this pull request
Jan 23, 2021
Inheriting from AdminController gives us rudimentary authorization based on user role (must be admin or sysadmin). See #835. Also changes one occurrence of the deprecated `update_attributes` -> `update`.
5 tasks
solebared
added a commit
that referenced
this pull request
Jan 25, 2021
Inheriting from AdminController gives us rudimentary authorization based on user role (must be admin or sysadmin). See #835. Also changes one occurrence of the deprecated `update_attributes` -> `update`.
h-m-m
approved these changes
Jan 26, 2021
Collaborator
h-m-m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty happy about where we landed with this
solebared
added a commit
that referenced
this pull request
Jan 26, 2021
Inheriting from AdminController gives us rudimentary authorization based on user role (must be admin or sysadmin). See #835. Also changes one occurrence of the deprecated `update_attributes` -> `update`.
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.
Why
Before we open up user registration, we have to secure any pages that should only be accessible to admins (sysadmins). This actually turns out to be the vast majority of our controllers, so ideally we can solve this w/o a lot of drudge work.
Pre-Merge Checklist
What
AdminControllerthat ensures current_user is an admin || sysadminContactMethodsController)How
pundit, we would usuallyauthorizeeach action independently and create policy classes for each resource.before_actionseems like a simpler solution.AdminControllercontains a bunch of non-restful actions. I recommend we extract them out into their own controllers soAdminControllercan become an abstract base class.Testing
Added a spec specifically around the simple auth introduced in
AdminController. It usesContactMethodsControlleras a sample admin-only resource.Next Steps
AdminControllersince we don't want all subclasses to inherit this extraneous logic (Make admin controllers restful #836).AdminController(Add simple auth to all admin-only controllers #837).Outstanding Questions, Concerns and Other Notes
?