-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use pundit policy_namespace in controllers #2379
Use pundit policy_namespace in controllers #2379
Conversation
Fixes #1332 To use specific Policy Namespacing for authorization, like admin namespaced policies for example, just set the
|
Nice, thank you! I don't have much time now, but I'll review it a bit more thoroughly when I can. One thing is that ideally I'd like to have some sort of back-compatibility hook where we show a warning to people using the old interface. Do you know how we could achieve this? If you don't, it's ok, I'll get to it. At least this PR gets us moving. |
4fb6ee4
to
aab1325
Compare
Just added pundit policy scope |
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.
One thing I can't find a good place to put: I think we should remove OrderPolicy#resolve_admin
, for two reasons:
- It pollutes the specs with warnings.
- Our example app should avoid deprecated APIs.
The problem is that then this would break the specs you wrote to check for deprecations. I wonder if we can do this differently, perhaps adding #resolve_admin
in a before
block with metaprogramming, then remove it in the after
block. Thoughts? I'm happy with having a much simpler spec for this, instead of looking
Anyway, this is looking pretty good! I want to give it another review though, so make sure I'm not missing anything as this could have large repercussions for many people.
Also I wonder if @nickcharlton or @littleforest would have some time to have a look too 👀
9fb1aab
to
98c92e9
Compare
Totally agree. I've addressed those issues. Thank you! |
f06c9f3
to
c700025
Compare
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.
We are getting there! Once we resolve the open threads, I think this can be merged if my colleagues don't have any other comments.
Add pundit policy_namespaces to controllers Remove resolve_admin from pundit policies
Add pundit policy scope resolve_admin method deprecation
Fix hound errors
Replace #policy_namespaces with ::pundit_policy_namespace in controllers Remove unnecessary namespaced_policy_scope private method from punditize Remove unnecessary guard in punditize policy_scope! Remove deprecated resolve_admin from spec example app policy scope
Fix pundit_policy_namespace inheritance
c700025
to
51cc9fd
Compare
I've addressed the open issues and rebased to main. Thank you @pablobm! |
Revert pundit_policy_namespace use in controllers Use pundit policy_namespace in controllers
51cc9fd
to
6ff8e26
Compare
Let's go go go! 🚀 |
Thank you @bhtabor 🙂 |
Add pundit policy_namespace to controllers
Deprecate resolve_admin from pundit policies