Use Omniauth.allowed_methods' as routing verbs for the auth path: #5508
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.
Use Omniauth.allowed_methods' as routing verbs for the auth path:
Context
Since version 2.0.0, Omniauth no longer recognizes
GET
requeston the auth path (
/users/auth/<provider>
).POST
is the onlyverb that is by default recognized in order to mitigate CSRF
attack. https://github.com/omniauth/omniauth/blob/66110da85e3106d9c9b138d384267a9397c75fe7/lib/omniauth/strategy.rb#L205
Ultimatelly, when a user try to access
GET /users/auth/facebook
,Devise passthru action will be called which just return a raw 404 page.
Problem
There is no problem per se and everything work. However the
advantage of not matching GET request at the router layer allows
to get that same 404 page stylized for "free" (Rails ending up
rendering the 404 page of the app).
I believe it's also more consistent and less surprising for users
if this passthru action don't get called.
Drawback
An application can no longer override the
passthru
to performthe logic it wants (i.e. redirect the user). (Though, worth to mention that the
passthru
action was originally not meant to be used as fallback main_app.user_omniauth_authorize_path throws error #1843 (comment) , but maybe this has become a hidden feature over the years :D)If this is a dealbreaker, feel free to close this PR :).