Run setup phase before logout #205
Open
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.
This PR allows a dynamic post logout redirect uri, using the setup from omniauth
Why
I have an application where the redirect_uri for the logout depends on the request (one strategy is applied for multiple (sub)domains that each have their own keys and their own
redirect_uri
andpost_logout_redirect_uri
).I naively assumed that the following would work (simplified for clarity)
However I discovered that the setup phase does not get called on logout.
Solution
If the request is a logout request, I mimicked the way
OmniAuth::Strategy
runs the setup when the request is a request or callback. I imagine it doesn't make sense forOmniAuth::Strategy
to do this beforeother_phase
since that would mean running the setup before every request in the application. This makes that the config above would work (I also validated this in my actual application using this version)I also considered changing
post_logout_redirect_uri
to accept a string or a proc. I found it more intuitive that we would re-use the setup, but I'm happy to still switch this around. The initializer for my example would then be: