-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unauthorized redirect handling config #6051
Open
mamhoff
wants to merge
4
commits into
solidusio:main
Choose a base branch
from
mamhoff:unauthorized-redirect-handling-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Unauthorized redirect handling config #6051
mamhoff
wants to merge
4
commits into
solidusio:main
from
mamhoff:unauthorized-redirect-handling-config
+101
−16
Conversation
This file contains 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
github-actions
bot
added
changelog:solidus_backend
Changes to the solidus_backend gem
changelog:solidus_core
Changes to the solidus_core gem
changelog:solidus_admin
labels
Dec 21, 2024
mamhoff
added a commit
to mamhoff/solidus_auth_devise
that referenced
this pull request
Dec 21, 2024
This makes the `prepare_{frontend,backend}` methods which instantiate the base controller and the admin base controller, requiring all of ActionController::Base, unnecessary to call for newer Solidus versions. Depends on solidusio/solidus#6051
3 tasks
mamhoff
added a commit
to mamhoff/solidus_auth_devise
that referenced
this pull request
Dec 21, 2024
This makes the `prepare_{frontend,backend}` methods which instantiate the base controller and the admin base controller, requiring all of ActionController::Base, unnecessary to call for newer Solidus versions. Depends on solidusio/solidus#6051
mamhoff
force-pushed
the
unauthorized-redirect-handling-config
branch
from
December 23, 2024 13:43
f24f2ae
to
7753b24
Compare
adammathys
approved these changes
Jan 3, 2025
forkata
approved these changes
Jan 8, 2025
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.
Thanks @mamhoff! I think there are some failing specs because we're modifying global configuration in one of the specs added, but otherwise this change looks great and it'll make overriding this behaviour much easier on stores that require more granular permissions.
mamhoff
force-pushed
the
unauthorized-redirect-handling-config
branch
4 times, most recently
from
January 9, 2025 13:21
6471920
to
c259ad3
Compare
This lambda has to be set on the instantiated class, requiring the controller it's set on to be autoloaded on boot. Loading a controller also loads all helpers, and that takes quite a bit of time. So this comes with a performance benefit, because neither the controller nor the handler need to be loaded at configuration time.
The previous `unauthorized_redirect` can really only be set globally, but it's a common use case to handle unauthorized access differently for the admin. This adds a configuration option for the admin base controller, allowing customizers to set that behavior without having to patch any controller.
Customizers can now set their own unauthorized_redirect class with any behavior from the controller they might need. There's no need for this suggestion (and the comment is not entirely true either, as the handler provided does not re-raise the exception, but raises another one).
This make sure the admin also uses the configured redirect handler class.
mamhoff
force-pushed
the
unauthorized-redirect-handling-config
branch
from
January 9, 2025 13:35
c259ad3
to
cc0a2eb
Compare
jarednorman
approved these changes
Jan 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
changelog:solidus_admin
changelog:solidus_backend
Changes to the solidus_backend gem
changelog:solidus_core
Changes to the solidus_core gem
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.
Summary
This replaces the
unauthorized_redirect
lambda that can be set on any controller with two configurable classes that are by default both set to the same defaultSpree::UnauthorizedRedirectHandler
. Two, because frontend and backend will require different strategies in many cases (not least in the case of thesolidus_auth_devise
extension).Care has been taken to maintain the legacy behavior and print out deprecation warnings.
A big part of the reason is that setting the lamda on the controllers requires loading the controllers, making us need to use a
config.to_prepare
block as well as making us inadvertently eager-load a lot of code.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: