-
-
Notifications
You must be signed in to change notification settings - Fork 303
Description
With this update from Doorkeeper, existing authorization flows stopped working. This is no longer the case since this update on Doorkeeper was reverted.
However, it seemed to me that there is a strange behaviour when I was debugging to see why this was no longer working.
A couple of pry's later I figured out what's going on. I will use an example as it's a bit complicated to explain:
Resource server on localhost:3000
Authorization server on localhost:5000
- Registered client
redirect_urion Doorkeeper (authorization server) side is:http://localhost:3000/auth/some_provider/callback - During authorization request phase, the client issues the proper authorization request url like:
http://localhost:5000/oauth/authorize?client_id=some_client_id&&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%some_provider%2Fcallback&response_type=code&state=some_state - Authorization server does the authorization and redirects back to
http://localhost:3000/auth/some_provider/callback?code=some_authorization_code&state=some_state - Now the client needs to exchange the code for the access token from the authorization server, however, while constructing the request it uses the
redirect_uriusing thiscallback_urlmethod defined inomniauthwhich adds therequest.query_stringto thecallback_url. So the code exchange request becomes:POST http://localhost:5000/oauth/tokenwith params:
client_id: some_client_id,
client_secret: some_client_secret,
code: some_authorization_code,
redirect_uri: http://localhost:3000/auth/some_provider/callback?code=some_authorization_code&state=some_state
and this is where it is questionable whether the code and state should be replied back to the authorization server as part of the redirect_uri even though they didn't originally exist in the request phase. And this is where the reverted update was facing an issue as it couldn't fully match the redirect_uri with these extra query params against the one(s) defined on the authorization server during registration of the client.
This is the source of it in omniauth, I honestly did not dive deep enough in the spec to know what is the expected behaviour, however, this behaviour doesn't look correct.