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

Remove telemetry from authorize URL #75

Merged
merged 1 commit into from
Mar 27, 2019
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
12 changes: 6 additions & 6 deletions lib/omniauth/strategies/auth0.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'base64'
require 'uri'
require 'omniauth-oauth2'
Expand Down Expand Up @@ -75,16 +77,14 @@ def client
# Define the parameters used for the /authorize endpoint
def authorize_params
params = super
params['auth0Client'] = telemetry_encoded
parse_query = Rack::Utils.parse_query(request.query_string)
params['connection'] = parse_query['connection']
params['prompt'] = parse_query['prompt']
parsed_query = Rack::Utils.parse_query(request.query_string)
params['connection'] = parsed_query['connection']
params['prompt'] = parsed_query['prompt']
params
end

def build_access_token
telemetry_header = { 'Auth0-Client' => telemetry_encoded }
options.token_params.merge!(:headers => telemetry_header)
options.token_params[:headers] = { 'Auth0-Client' => telemetry_encoded }
Copy link
Contributor

Choose a reason for hiding this comment

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

previously this said "merge". Isn't this now a replace rather than a merge? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be doing the same. Previous was merging options.token_params with :headers => telemetry_header, not merging headers (since :headers might not be a hash or even exist).

super
end

Expand Down
6 changes: 4 additions & 2 deletions spec/omniauth/strategies/auth0_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you need to add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rubocop suggestion, I don't think it has much effect on what's happening here but idiomatic.


require 'spec_helper'
require 'jwt'

Expand Down Expand Up @@ -79,7 +81,7 @@
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('auth0Client')
expect(redirect_url).not_to have_query('auth0Client')
end

it 'redirects to hosted login page' do
Expand All @@ -92,7 +94,7 @@
expect(redirect_url).to have_query('client_id')
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).to have_query('connection', 'abcd')
expect(redirect_url).to have_query('auth0Client')
expect(redirect_url).not_to have_query('auth0Client')
end

describe 'callback' do
Expand Down