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

Fix strategy configuration #1

Merged
merged 1 commit into from
Jul 5, 2022
Merged
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
26 changes: 15 additions & 11 deletions lib/omniauth/strategies/qualtrics.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
require "omniauth-oauth2"
require 'omniauth-oauth2'

module OmniAuth
module Strategies
class Qualtrics < OmniAuth::Strategies::OAuth2

option :name, "qualtrics"
option :name, 'qualtrics'

option :client_options,
site: "https://co1.qualtrics.com",
authorize_url: "/oauth2/auth",
token_url: "/oauth2/token"
site: 'https://co1.qualtrics.com',
authorize_url: '/oauth2/auth',
token_url: '/oauth2/token'

# Qualtrics does use state but we want to control it rather than letting
# omniauth-oauth2 handle it.
Expand All @@ -19,26 +18,31 @@ class Qualtrics < OmniAuth::Strategies::OAuth2

info do
{
"url" => access_token.client.site
'url' => access_token.client.site
}
end

def callback_url
full_host + script_name + callback_path
end
Comment on lines +25 to +27
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We got an error saying it was missing required parameters which is the same error we got with SurveyMonkey so we tried the same remedy and it worked

Copy link

Choose a reason for hiding this comment

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

is this overriding a method from super or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. I can see if I can find the original explanation of it for SurveyMonkey...

Copy link
Collaborator Author

@smcabrera smcabrera Jul 1, 2022

Choose a reason for hiding this comment

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

Here's the same change we made for SurveyMonkey user-interviews/omniauth-surveymonkey-oauth2#1

Based on an identical change for the twitch gem

image

Here's the original omniauth change that broke things for a lot of gems omniauth/omniauth-oauth2#70

Copy link

Choose a reason for hiding this comment

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

twitch integration when


# Override authorize_params so that we can be deliberate about the value for state
# and not use the session which is unavailable inside of an iframe for some
# browsers (ie Safari)
def authorize_params
# Only set state if it hasn't already been set
options.authorize_params[:state] ||= SecureRandom.hex(24)
params = options.authorize_params.merge(options_for("authorize"))
options.authorize_params[:scope] = 'manage:all'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not ideal--we'd rather it have just the scopes that we need, which you should be able to do by setting them in the omniauth config...but I tried that and it didn't work. We can try to look into a better solution in the future.

params = options.authorize_params.merge(options_for('authorize'))
if OmniAuth.config.test_mode
@env ||= {}
@env["rack.session"] ||= {}
@env['rack.session'] ||= {}
end
params
end

end
end
end

OmniAuth.config.add_camelization "qualtrics", "Qualtrics"
OmniAuth.config.add_camelization 'qualtrics', 'Qualtrics'