Skip to content

Commit c0b0eab

Browse files
authored
Fix common bug in omniauth strategies
This change fixes the configuration addressing a common bug across omniauth strategies that was introduced back in omniauth/omniauth-oauth2#70
2 parents 4bb3d5a + aef8d86 commit c0b0eab

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/omniauth/strategies/qualtrics.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
require "omniauth-oauth2"
1+
require 'omniauth-oauth2'
22

33
module OmniAuth
44
module Strategies
55
class Qualtrics < OmniAuth::Strategies::OAuth2
6-
7-
option :name, "qualtrics"
6+
option :name, 'qualtrics'
87

98
option :client_options,
10-
site: "https://co1.qualtrics.com",
11-
authorize_url: "/oauth2/auth",
12-
token_url: "/oauth2/token"
9+
site: 'https://co1.qualtrics.com',
10+
authorize_url: '/oauth2/auth',
11+
token_url: '/oauth2/token'
1312

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

2019
info do
2120
{
22-
"url" => access_token.client.site
21+
'url' => access_token.client.site
2322
}
2423
end
2524

25+
def callback_url
26+
full_host + script_name + callback_path
27+
end
28+
2629
# Override authorize_params so that we can be deliberate about the value for state
2730
# and not use the session which is unavailable inside of an iframe for some
2831
# browsers (ie Safari)
2932
def authorize_params
3033
# Only set state if it hasn't already been set
3134
options.authorize_params[:state] ||= SecureRandom.hex(24)
32-
params = options.authorize_params.merge(options_for("authorize"))
35+
options.authorize_params[:scope] = 'manage:all'
36+
params = options.authorize_params.merge(options_for('authorize'))
3337
if OmniAuth.config.test_mode
3438
@env ||= {}
35-
@env["rack.session"] ||= {}
39+
@env['rack.session'] ||= {}
3640
end
3741
params
3842
end
39-
4043
end
4144
end
4245
end
4346

44-
OmniAuth.config.add_camelization "qualtrics", "Qualtrics"
47+
OmniAuth.config.add_camelization 'qualtrics', 'Qualtrics'
48+

0 commit comments

Comments
 (0)