Skip to content

Commit

Permalink
Merge pull request #99 from felixclack/connection-scope
Browse files Browse the repository at this point in the history
Add support for `connection_scope` in params
  • Loading branch information
lbalmaceda authored Apr 1, 2020
2 parents e514846 + 1cf2b95 commit ed9f4e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/omniauth/strategies/auth0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def client
def authorize_params
params = super
parsed_query = Rack::Utils.parse_query(request.query_string)
%w[connection prompt].each do |key|
%w[connection connection_scope prompt].each do |key|
params[key] = parsed_query[key] if parsed_query.key?(key)
end

# Generate nonce
params[:nonce] = SecureRandom.hex
# Generate leeway if none exists
params[:leeway] = 60 unless params[:leeway]

# Store authorize params in the session for token verification
session['authorize_params'] = params

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

it 'redirects to the hosted login page with connection_scope' do
get 'auth/auth0?connection_scope=identity_provider_scope'
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('connection_scope', 'identity_provider_scope')
end

it 'redirects to hosted login page with prompt=login' do
get 'auth/auth0?prompt=login'
expect(last_response.status).to eq(302)
Expand Down

0 comments on commit ed9f4e4

Please sign in to comment.