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

Add support for screen_hint=signup param #103

Merged
merged 5 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
codecov (0.1.16)
codecov (0.2.7)
colorize
json
simplecov
url
coderay (1.1.2)
colorize (0.8.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
daemons (1.3.1)
Expand Down Expand Up @@ -44,7 +45,7 @@ GEM
hashdiff (1.0.1)
hashie (4.1.0)
jaro_winkler (1.5.4)
json (2.3.0)
json (2.3.1)
jwt (2.2.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -119,7 +120,7 @@ GEM
shellany (0.0.1)
shotgun (0.9.2)
rack (>= 1.0)
simplecov (0.18.5)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
Expand All @@ -135,7 +136,6 @@ GEM
thor (1.0.1)
tilt (2.0.10)
unicode-display_width (1.7.0)
url (0.3.2)
webmock (3.8.3)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/auth0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def client
def authorize_params
params = super
parsed_query = Rack::Utils.parse_query(request.query_string)
%w[connection connection_scope prompt].each do |key|
%w[connection connection_scope prompt screen_hint].each do |key|
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this line doing, allowing these keys to be taken from the URL query and setting them on the /authorize call?

params[key] = parsed_query[key] if parsed_query.key?(key)
end

Expand Down
14 changes: 14 additions & 0 deletions spec/omniauth/strategies/auth0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@
expect(redirect_url).not_to have_query('connection')
end

it 'redirects to hosted login page with screen_hint=signup' do
get 'auth/auth0?screen_hint=signup'
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a existing test for checking that on a "normal authorize call" (without extra args) these keys are not part of the query. Let's add this one there, and also the ones that are missing from previous changes.

The test is on these lines:

expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
expect(redirect_url).not_to have_query('prompt')

Let's add a line for testing that the following keys are NOT in the query:

  • connection_scope
  • screen_hint

expect(last_response.status).to eq(302)
redirect_url = last_response.headers['Location']
expect(redirect_url).to start_with('https://samples.auth0.com/authorize')
expect(redirect_url).to have_query('response_type', 'code')
expect(redirect_url).to have_query('state')
expect(redirect_url).to have_query('client_id')
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).to have_query('screen_hint', 'signup')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
end

describe 'callback' do
let(:access_token) { 'access token' }
let(:expires_in) { 2000 }
Expand Down