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 login_hint to permitted params #123

Merged
merged 4 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/auth0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def client
# Define the parameters used for the /authorize endpoint
def authorize_params
params = super
%w[connection connection_scope prompt screen_hint organization invitation].each do |key|
%w[connection connection_scope prompt screen_hint login_hint organization invitation].each do |key|
params[key] = request.params[key] if request.params.key?(key)
end

Expand Down
50 changes: 50 additions & 0 deletions spec/omniauth/strategies/auth0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
expect(redirect_url).not_to have_query('login_hint')
expect(redirect_url).not_to have_query('organization')
expect(redirect_url).not_to have_query('invitation')
end

it 'redirects to hosted login page' do
Expand All @@ -107,6 +110,9 @@
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
expect(redirect_url).not_to have_query('login_hint')
expect(redirect_url).not_to have_query('organization')
expect(redirect_url).not_to have_query('invitation')
end

it 'redirects to the hosted login page with connection_scope' do
Expand All @@ -130,6 +136,9 @@
expect(redirect_url).to have_query('prompt', 'login')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
expect(redirect_url).not_to have_query('login_hint')
expect(redirect_url).not_to have_query('organization')
expect(redirect_url).not_to have_query('invitation')
end

it 'redirects to hosted login page with screen_hint=signup' do
Expand All @@ -144,6 +153,47 @@
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')
expect(redirect_url).not_to have_query('login_hint')
expect(redirect_url).not_to have_query('organization')
expect(redirect_url).not_to have_query('invitation')
end

it 'redirects to hosted login page with organization=TestOrg and invitation=TestInvite' do
get 'auth/auth0?organization=TestOrg&invitation=TestInvite'
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('organization', 'TestOrg')
expect(redirect_url).to have_query('invitation', 'TestInvite')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
expect(redirect_url).not_to have_query('login_hint')
end

it 'redirects to hosted login page with login_hint=example@mail.com' do
get 'auth/auth0?login_hint=example@mail.com'
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('login_hint', 'example@mail.com')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
expect(redirect_url).not_to have_query('organization')
expect(redirect_url).not_to have_query('invitation')
end

describe 'callback' do
Expand Down