Skip to content
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

Migrate Pundit to Action Policy to pass message and redirect URL on authorization failure #395

Closed
3 tasks
joemasilotti opened this issue Apr 30, 2022 · 3 comments
Labels
help wanted Looking for help from the community

Comments

@joemasilotti
Copy link
Owner

joemasilotti commented Apr 30, 2022

Pundit, the authorization gem, doesn't support passing "context" when raising an error. Action Policy does. I want to pass context to display a custom error message and redirect based on what kind of authorization failed.

A PR addressing this issue should:

  • Follow the migration guide
  • Abstract adding error message and redirect path to ApplicationPolicy
  • Implement ColdMessagePolicy to handle the different failure paths (see the before_actions in ColdMessageController)

I'm open to lots of discussion on this one as I'n not 100% sure Action Policy is the right move. So feel free to submit a draft PR to kick off a conversation!

@joemasilotti joemasilotti self-assigned this Apr 30, 2022
@joemasilotti joemasilotti removed their assignment May 9, 2022
@joemasilotti joemasilotti changed the title Spike on Action Policy to pass message and redirect URL on authorization failure Migrate Pundit to Action Policy to pass message and redirect URL on authorization failure May 9, 2022
@joemasilotti joemasilotti added the help wanted Looking for help from the community label May 9, 2022
@djdarkbeat
Copy link

We're thinking about migrating to action policy at work from petergate (https://github.com/elorest/petergate) Petergate is being used in two repos, but we have i18n issues to support and there's the whole passing context thing to consider also. I have to admit being curious about this but I also know I can't commit to look at it until after RailsConf.

@joemasilotti
Copy link
Owner Author

I doubt I'll get around to it before then, either. But glad to know other folks are thinking along the same lines as me!

@joemasilotti
Copy link
Owner Author

Closed via #447. I'll probably come back to this, but shoving error messages and redirection URLs in the policy layer feels weird right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Looking for help from the community
Projects
Status: Ready to work on
Development

No branches or pull requests

2 participants