omniauth-oauth2 icon indicating copy to clipboard operation
omniauth-oauth2 copied to clipboard

callback_url definition

Open blarralde opened this issue 12 years ago • 10 comments

Hello

Is there any reason why callback_url is overriden line 37? It's losing query_string from its original definition, which I find very useful...

Cheers Ben

blarralde avatar Jan 11 '13 18:01 blarralde

I couldn't find a reason as to why this would be the case. I would like @mbleigh to weigh in before merging this into master.

Per RFC3986:

The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per Appendix B) query component ([RFC3986] Section 3.4), which MUST be retained when adding additional query parameters.

http://tools.ietf.org/html/rfc6749#section-3.1.2

tmilewski avatar Sep 04 '13 20:09 tmilewski

Is there any news on this? It took me quite some time debugging why the callback url would lose the querystring.

jeroenj avatar Feb 24 '14 15:02 jeroenj

Patch breaks google oauth2, but twitter and facebook work fine.

h0tw1r3 avatar Oct 01 '14 19:10 h0tw1r3

Breaks Spotify and Beats (which do not accept callback urls with get params).

You can use request.env['omniauth.params'] in callback controller

stereobooster avatar Mar 17 '15 19:03 stereobooster

@stereobooster, request.env['omniauth.params'] is nil inside my callback controller.

chamnap avatar Mar 25 '15 06:03 chamnap

A little silent in here...

I think the override was removed in https://github.com/intridea/omniauth-oauth2/pull/70.

However, now the callback_url contains the code and state query parameters for me:

>>  callback_url
=> "http://localhost:3005/auth/XXX/callback?code=63e874156af1c6e9c056c34f5225ac7fa58f4cb0ba1ce19f12674fe51f20739c&state=864417e69b314d78dd33201169c7ca58dad54070ea6f80f1"

At least the code parameter was provided by the AS in response to the Authorization Request. However, a spec compliant AS must compare the redirect_uri it received in the Authorization Request with the one in the Access Token Request.

Since the former request could not possibly contain the code parameter, this parameter (and probably also state) should not be transmitted in the latter request.

tl; dr: By transmitting the code parameter in the Access Token Request, the AS verification of the redirect_uri fails.

I don't quite know why this is no issue for many more people...

NobodysNightmare avatar Mar 21 '16 17:03 NobodysNightmare

+1 sameissue here

caseyprovost avatar Jun 07 '16 11:06 caseyprovost

I had the same issue @NobodysNightmare mentioned above — the removal of the callback_url definition in #70 broke my custom strategies, because the redirect_uri during the callback phase does not match the original one.

I had to add this to all my custom strategies to get them working again.

def callback_url
  full_host + callback_path
end

I also use omnituah-google-oauth2, which continued to work after #70, and I was wondering why it didn't have the same problem with redirect_url mismatch, and it's because it has basically the same override.

jmanian avatar Aug 24 '22 20:08 jmanian

I just ran into this issue with trying to implement Airtable; Where they were rejecting the redirect_uri if it had the additional QSP.

While it seems like the spec is well defined, it does seem common enough of an implementation detail that it might be wise to uplevel this to an option that may be configured depending on how the server is behaving.

sirwolfgang avatar Dec 30 '22 22:12 sirwolfgang

Chiming in from Airtable, our reading of RFC3986:

The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per Appendix B) query component ([RFC3986] Section 3.4), which MUST be retained when adding additional query parameters.

http://tools.ietf.org/html/rfc6749#section-3.1.2

was that query parameters included in redirect URI stored in authorization server's database must be preserved. e.g. if you've registered the URI https://www.mysite.com/oauth-redirect?myParam=staticArg then myParam=staticArg must be preserved when we redirect the user, note that we should allow additional or dynamic query parameters during authorization (we may relax this in the future but I can't offer any timelines, sorry!)

WillPowelson-at avatar Jan 03 '23 20:01 WillPowelson-at