Skip to content
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

Make native redirect code a query param #1003

Merged
merged 1 commit into from
Jan 29, 2018

Conversation

dv
Copy link
Contributor

@dv dv commented Nov 30, 2017

Using native redirect, instead of redirecting to

oauth/authorize/abc123abc123

it redirects to

oauth/authorize/native?code=abc123abc123

This allows for automated flows to detect that an Authorization code was granted in much the same way as a normal redirect. This is used by e.g. Mac Paw (and possibly Postman) to detect whether a code was given or not. I'm not sure if this was intentional or not, but adding the code as an actual param would make sense to mimic the non-oob flow as much as possible, gaining support by any software that works with non-oob flow.

Before:

After:

Related

@@ -154,7 +154,7 @@ def translated_error_message(key)

it 'should redirect immediately' do
expect(response).to be_redirect
expect(response.location).to match(/oauth\/authorize\//)
expect(response.location).to match(/oauth\/authorize\/native?code=/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %r around regular expression.

@@ -49,7 +49,7 @@ def authorization_routes(mapping)
as: mapping[:as],
controller: mapping[:controllers]
) do
routes.get '/:code', action: :show, on: :member
routes.get '/native', action: :show, on: :member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@dv dv force-pushed the make-native-auth-code-a-param branch from 267a544 to 185c9f5 Compare November 30, 2017 07:07
@nbulaj nbulaj self-assigned this Jan 27, 2018
@nbulaj
Copy link
Member

nbulaj commented Jan 29, 2018

Hi @dv. Looks good to me. One moment: can you improve specs to check if valid code present in the code parameter?

Also, could you please add an entry on the top of the NEWS.md and rebase with squashing? Thanks!

@@ -154,7 +154,7 @@ def translated_error_message(key)

it 'should redirect immediately' do
expect(response).to be_redirect
expect(response.location).to match(/oauth\/authorize\//)
expect(response.location).to match(/oauth\/authorize\/native\?code=#{Doorkeeper::AccessGrant.first.token}/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %r around regular expression.
Line is too long. [113/80]

@@ -29,6 +29,7 @@

access_grant_should_exist_for(@client, @resource_owner)

url_should_have_param('code', Doorkeeper::AccessGrant.first.token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@dv dv force-pushed the make-native-auth-code-a-param branch from 90c5ca0 to 7dea128 Compare January 29, 2018 19:01
This allows for automated flows to detect that an Authorization code was granted in much the same way as a normal redirect. This is used by e.g. Mac Paw.
@dv dv force-pushed the make-native-auth-code-a-param branch from 7dea128 to 2236363 Compare January 29, 2018 19:05
@dv
Copy link
Contributor Author

dv commented Jan 29, 2018

Hey @nbulaj, thanks! Did as requested, is this ok?

@nbulaj nbulaj merged commit 328765c into doorkeeper-gem:master Jan 29, 2018
@nbulaj
Copy link
Member

nbulaj commented Jan 29, 2018

Great, thanks @dv!

pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
pakwfoley pushed a commit to pakwfoley/doorkeeper that referenced this pull request Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants