omniauth_oidc 0.2.7 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +124 -0
- data/LICENSE.txt +1 -1
- data/README.md +186 -71
- data/lib/omniauth/oidc/client.rb +86 -0
- data/lib/omniauth/oidc/config_fetcher.rb +114 -0
- data/lib/omniauth/oidc/errors.rb +20 -1
- data/lib/omniauth/oidc/http_client.rb +103 -0
- data/lib/omniauth/oidc/jwk_handler.rb +48 -0
- data/lib/omniauth/oidc/jwks_cache.rb +30 -0
- data/lib/omniauth/oidc/logging.rb +76 -0
- data/lib/omniauth/oidc/response_objects.rb +176 -0
- data/lib/omniauth/oidc/ttl_cache.rb +82 -0
- data/lib/omniauth/oidc/version.rb +1 -1
- data/lib/omniauth/strategies/oidc/callback.rb +137 -90
- data/lib/omniauth/strategies/oidc/redirect_uri.rb +59 -0
- data/lib/omniauth/strategies/oidc/request.rb +27 -19
- data/lib/omniauth/strategies/oidc/verify.rb +172 -68
- data/lib/omniauth/strategies/oidc.rb +97 -38
- data/lib/omniauth_oidc.rb +8 -0
- data/omniauth_oidc.gemspec +8 -5
- data/sig/omniauth_oidc.rbs +214 -1
- metadata +46 -34
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OmniauthOidc
|
|
4
|
+
# Thread-safe cache with a per-entry TTL.
|
|
5
|
+
#
|
|
6
|
+
# Reads take a short global lock only. Fetches run under a per-key lock, so a
|
|
7
|
+
# slow or hanging upstream for one key never blocks cache hits for other keys,
|
|
8
|
+
# and concurrent misses for the same key trigger a single fetch.
|
|
9
|
+
class TtlCache
|
|
10
|
+
Entry = Struct.new(:value, :fetched_at, keyword_init: true)
|
|
11
|
+
|
|
12
|
+
attr_reader :ttl
|
|
13
|
+
|
|
14
|
+
def initialize(ttl:, name: "TTL")
|
|
15
|
+
@ttl = ttl
|
|
16
|
+
@name = name
|
|
17
|
+
@entries = {}
|
|
18
|
+
@locks = {}
|
|
19
|
+
@mutex = Mutex.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns the cached value for key, calling the block to fetch it on a miss.
|
|
23
|
+
#
|
|
24
|
+
# ttl: seconds an entry stays valid (defaults to the cache TTL)
|
|
25
|
+
# force_refresh: fetch even if the entry is still valid
|
|
26
|
+
# min_age: with force_refresh, reuse an entry fetched less than this many
|
|
27
|
+
# seconds ago. Rate limits refreshes that callers can trigger.
|
|
28
|
+
def fetch(key, force_refresh: false, ttl: nil, min_age: 0, &block)
|
|
29
|
+
ttl ||= @ttl
|
|
30
|
+
entry = read(key)
|
|
31
|
+
return hit(key, entry) if !force_refresh && younger_than?(entry, ttl)
|
|
32
|
+
|
|
33
|
+
lock_for(key).synchronize do
|
|
34
|
+
# Another thread may have fetched while this one waited for the lock
|
|
35
|
+
entry = read(key)
|
|
36
|
+
return hit(key, entry) if younger_than?(entry, force_refresh ? min_age : ttl)
|
|
37
|
+
|
|
38
|
+
Logging.info("#{@name} cache miss, fetching", key: key, force_refresh: force_refresh)
|
|
39
|
+
value = block.call
|
|
40
|
+
@mutex.synchronize { @entries[key] = Entry.new(value: value, fetched_at: Time.now) }
|
|
41
|
+
value
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def valid?(key)
|
|
46
|
+
younger_than?(read(key), @ttl)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def invalidate(key)
|
|
50
|
+
@mutex.synchronize { @entries.delete(key) }
|
|
51
|
+
Logging.debug("#{@name} cache invalidated", key: key)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def clear!
|
|
55
|
+
@mutex.synchronize { @entries.clear }
|
|
56
|
+
Logging.debug("#{@name} cache cleared")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def ttl=(value)
|
|
60
|
+
@mutex.synchronize { @ttl = value }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def read(key)
|
|
66
|
+
@mutex.synchronize { @entries[key] }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def hit(key, entry)
|
|
70
|
+
Logging.debug("#{@name} cache hit", key: key)
|
|
71
|
+
entry.value
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def younger_than?(entry, seconds)
|
|
75
|
+
!entry.nil? && Time.now - entry.fetched_at < seconds
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def lock_for(key)
|
|
79
|
+
@mutex.synchronize { @locks[key] ||= Mutex.new }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -3,120 +3,157 @@
|
|
|
3
3
|
module OmniAuth
|
|
4
4
|
module Strategies
|
|
5
5
|
class Oidc
|
|
6
|
-
# Callback phase
|
|
7
|
-
module Callback
|
|
8
|
-
def callback_phase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
# Callback phase - handles OIDC provider response
|
|
7
|
+
module Callback # rubocop:disable Metrics/ModuleLength
|
|
8
|
+
def callback_phase
|
|
9
|
+
OmniauthOidc::Logging.instrument("callback_phase.start", provider: name) do
|
|
10
|
+
handle_callback_errors do
|
|
11
|
+
validate_callback_params!
|
|
12
|
+
next missing_response_type_failure unless params.key?(configured_response_type)
|
|
13
|
+
|
|
14
|
+
options.issuer = issuer if options.issuer.nil? || options.issuer.empty?
|
|
15
|
+
|
|
16
|
+
client.redirect_uri = redirect_uri
|
|
17
|
+
|
|
18
|
+
if configured_response_type == "id_token"
|
|
19
|
+
handle_id_token_response
|
|
20
|
+
else
|
|
21
|
+
handle_code_response
|
|
22
|
+
end
|
|
23
|
+
verify_subject!
|
|
24
|
+
|
|
25
|
+
super
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
private
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
def handle_callback_errors
|
|
33
|
+
yield
|
|
29
34
|
rescue CallbackError => e
|
|
35
|
+
OmniauthOidc::Logging.error("Callback error", error: e.error, reason: e.error_reason)
|
|
30
36
|
fail!(e.error, e)
|
|
31
|
-
rescue ::
|
|
32
|
-
|
|
37
|
+
rescue OmniauthOidc::ConfigurationError, OmniauthOidc::JwksError => e
|
|
38
|
+
OmniauthOidc::Logging.error("Provider setup error", error: e.class.name, message: e.message)
|
|
39
|
+
fail!(e.is_a?(OmniauthOidc::JwksError) ? :jwks_error : :configuration_error, e)
|
|
40
|
+
rescue OmniauthOidc::TokenError => e
|
|
41
|
+
OmniauthOidc::Logging.error("Token error", error: e.class.name, message: e.message)
|
|
42
|
+
fail!(:token_error, e)
|
|
43
|
+
rescue OmniauthOidc::HttpClient::HttpError => e
|
|
44
|
+
OmniauthOidc::Logging.error("HTTP error", message: e.message)
|
|
45
|
+
fail!(:http_error, e)
|
|
33
46
|
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
|
47
|
+
OmniauthOidc::Logging.error("Timeout error", message: e.message)
|
|
34
48
|
fail!(:timeout, e)
|
|
35
49
|
rescue ::SocketError => e
|
|
50
|
+
OmniauthOidc::Logging.error("Connection error", message: e.message)
|
|
36
51
|
fail!(:failed_to_connect, e)
|
|
37
52
|
end
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
def validate_callback_params!
|
|
55
|
+
error = params["error_reason"] || params["error"]
|
|
56
|
+
error_description = params["error_description"] || params["error_reason"]
|
|
57
|
+
invalid_state = (options.require_state && params["state"].to_s.empty?) || params["state"] != stored_state
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
if error
|
|
60
|
+
raise CallbackError, error: params["error"], error_reason: error_description,
|
|
61
|
+
error_uri: params["error_uri"]
|
|
62
|
+
end
|
|
63
|
+
raise CallbackError, error: :csrf_detected, error_reason: "Invalid 'state' parameter" if invalid_state
|
|
64
|
+
end
|
|
43
65
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
def missing_response_type_failure
|
|
67
|
+
error_attrs = RESPONSE_TYPE_EXCEPTIONS[configured_response_type]
|
|
68
|
+
fail!(error_attrs[:key], error_attrs[:exception_class].new(params["error"]))
|
|
69
|
+
end
|
|
48
70
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
end
|
|
71
|
+
def handle_code_response
|
|
72
|
+
# Get access token via token exchange
|
|
73
|
+
@access_token = fetch_access_token
|
|
53
74
|
|
|
54
|
-
|
|
75
|
+
# Verify the ID token from the token response once, and reuse the result below
|
|
76
|
+
@verified_id_token = verify_id_token!(@access_token.id_token)
|
|
55
77
|
|
|
56
|
-
|
|
78
|
+
# Fetch and set user info
|
|
79
|
+
@user_info = fetch_user_info
|
|
80
|
+
end
|
|
57
81
|
|
|
58
|
-
|
|
82
|
+
def handle_id_token_response
|
|
83
|
+
# For id_token response type, extract user data directly from the verified token
|
|
84
|
+
# to_s: a bare "?id_token" param is nil and must fail verification, not skip it
|
|
85
|
+
@verified_id_token = verify_id_token!(params["id_token"].to_s)
|
|
86
|
+
@user_info = OmniauthOidc::ResponseObjects::UserInfo.new(@verified_id_token.raw_attributes)
|
|
87
|
+
|
|
88
|
+
# Create a minimal access token structure for credentials
|
|
89
|
+
@access_token = OmniauthOidc::ResponseObjects::AccessToken.new(
|
|
90
|
+
id_token: params["id_token"],
|
|
91
|
+
access_token: nil,
|
|
92
|
+
refresh_token: nil,
|
|
93
|
+
expires_in: nil,
|
|
94
|
+
scope: nil
|
|
95
|
+
)
|
|
96
|
+
end
|
|
59
97
|
|
|
60
|
-
|
|
98
|
+
def fetch_access_token
|
|
99
|
+
OmniauthOidc::Logging.instrument("token.exchange", provider: name) do
|
|
100
|
+
token_request_params = {
|
|
101
|
+
code: authorization_code,
|
|
102
|
+
redirect_uri: redirect_uri
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# The verifier comes only from the session. Request params are attacker controlled.
|
|
106
|
+
token_request_params[:code_verifier] = stored_pkce_verifier if options.pkce
|
|
107
|
+
|
|
108
|
+
set_client_options_for_callback_phase
|
|
109
|
+
|
|
110
|
+
client.access_token!(token_request_params)
|
|
111
|
+
end
|
|
61
112
|
end
|
|
62
113
|
|
|
63
|
-
def
|
|
64
|
-
|
|
114
|
+
def stored_pkce_verifier
|
|
115
|
+
verifier = session.delete(session_key("pkce.verifier"))
|
|
116
|
+
return verifier unless verifier.to_s.empty?
|
|
65
117
|
|
|
66
|
-
|
|
118
|
+
raise OmniauthOidc::TokenError, "No PKCE code verifier stored in the session for this login"
|
|
67
119
|
end
|
|
68
120
|
|
|
69
|
-
def
|
|
70
|
-
return
|
|
121
|
+
def fetch_user_info
|
|
122
|
+
return minimal_user_info_from_token unless options.fetch_user_info
|
|
71
123
|
|
|
72
|
-
|
|
73
|
-
|
|
124
|
+
userinfo_data = OmniauthOidc::Logging.instrument("userinfo.fetch", provider: name) do
|
|
125
|
+
client.userinfo!(@access_token.access_token).raw_attributes
|
|
126
|
+
end
|
|
127
|
+
return OmniauthOidc::ResponseObjects::UserInfo.new(userinfo_data) unless @verified_id_token
|
|
128
|
+
|
|
129
|
+
id_token_claims = @verified_id_token.raw_attributes
|
|
130
|
+
# OIDC Core 5.3.4: UserInfo values must not be used unless its sub matches the ID token
|
|
131
|
+
unless userinfo_data["sub"] == id_token_claims["sub"]
|
|
132
|
+
OmniauthOidc::Logging.error("UserInfo sub does not match ID token sub, using ID token claims only")
|
|
133
|
+
return minimal_user_info_from_token
|
|
134
|
+
end
|
|
74
135
|
|
|
75
|
-
|
|
136
|
+
OmniauthOidc::ResponseObjects::UserInfo.new(id_token_claims.merge(userinfo_data))
|
|
137
|
+
rescue StandardError => e
|
|
138
|
+
OmniauthOidc::Logging.warn("Failed to fetch userinfo, falling back to ID token", error: e.message)
|
|
139
|
+
minimal_user_info_from_token
|
|
76
140
|
end
|
|
77
141
|
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
config.userinfo_endpoint, {
|
|
81
|
-
headers: {
|
|
82
|
-
"Authorization" => "Bearer #{@access_token}",
|
|
83
|
-
"Content-Type" => "application/json"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
)
|
|
142
|
+
def minimal_user_info_from_token
|
|
143
|
+
return empty_user_info unless @verified_id_token
|
|
87
144
|
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
refresh_token: @access_token.refresh_token,
|
|
101
|
-
expires_in: @access_token.expires_in,
|
|
102
|
-
scope: @access_token.scope
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
call_app!
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def define_access_token
|
|
109
|
-
env["omniauth.auth"] = AuthHash.new(
|
|
110
|
-
provider: name,
|
|
111
|
-
credentials: {
|
|
112
|
-
id_token: @access_token.id_token,
|
|
113
|
-
token: @access_token.access_token,
|
|
114
|
-
refresh_token: @access_token.refresh_token,
|
|
115
|
-
expires_in: @access_token.expires_in,
|
|
116
|
-
scope: @access_token.scope
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
call_app!
|
|
145
|
+
OmniauthOidc::ResponseObjects::UserInfo.new(@verified_id_token.raw_attributes)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# A login without a subject must never complete: a nil uid can match the wrong local account
|
|
149
|
+
def verify_subject!
|
|
150
|
+
return unless uid.to_s.empty?
|
|
151
|
+
|
|
152
|
+
raise OmniauthOidc::TokenVerificationError, "Neither the ID token nor UserInfo provided a subject (sub)"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def empty_user_info
|
|
156
|
+
OmniauthOidc::ResponseObjects::UserInfo.new({})
|
|
120
157
|
end
|
|
121
158
|
|
|
122
159
|
def configured_response_type
|
|
@@ -127,9 +164,19 @@ module OmniAuth
|
|
|
127
164
|
def set_client_options_for_callback_phase
|
|
128
165
|
client.host = host
|
|
129
166
|
client.redirect_uri = redirect_uri
|
|
130
|
-
client.authorization_endpoint =
|
|
131
|
-
client.token_endpoint =
|
|
132
|
-
client.userinfo_endpoint =
|
|
167
|
+
client.authorization_endpoint = config.authorization_endpoint
|
|
168
|
+
client.token_endpoint = config.token_endpoint
|
|
169
|
+
client.userinfo_endpoint = config.userinfo_endpoint
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Accessor for OmniAuth DSL blocks
|
|
173
|
+
def user_info
|
|
174
|
+
@user_info
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Accessor for OmniAuth DSL blocks
|
|
178
|
+
def access_token
|
|
179
|
+
@access_token
|
|
133
180
|
end
|
|
134
181
|
end
|
|
135
182
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OmniAuth
|
|
4
|
+
module Strategies
|
|
5
|
+
class Oidc
|
|
6
|
+
# The callback URL sent to the provider. The request and callback phases both read it from here,
|
|
7
|
+
# so the authorization request and the token exchange always send the same value (RFC 6749 4.1.3).
|
|
8
|
+
module RedirectUri
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def redirect_uri
|
|
12
|
+
configured_redirect_uri || "#{request.base_url}/auth/#{name}/callback"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# The redirect_uri option, or nil when it is not set.
|
|
16
|
+
# Raises ConfigurationError unless it is an absolute http(s) URL without a fragment (RFC 6749 3.1.2).
|
|
17
|
+
def configured_redirect_uri
|
|
18
|
+
value = options.redirect_uri
|
|
19
|
+
return if value.nil?
|
|
20
|
+
|
|
21
|
+
uri = parse_redirect_uri(value)
|
|
22
|
+
return value if uri.is_a?(URI::HTTP) && !uri.host.to_s.empty? && uri.fragment.nil?
|
|
23
|
+
|
|
24
|
+
raise OmniauthOidc::ConfigurationError,
|
|
25
|
+
"redirect_uri must be an absolute http(s) URL without a fragment, got #{value.inspect}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def parse_redirect_uri(value)
|
|
29
|
+
URI.parse(value.to_s)
|
|
30
|
+
rescue URI::InvalidURIError
|
|
31
|
+
raise OmniauthOidc::ConfigurationError, "redirect_uri is not a valid URL: #{value.inspect}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# OmniAuth only handles the provider's redirect on callback_path. A redirect_uri with any other path
|
|
35
|
+
# reaches the host app unauthenticated, unless a proxy rewrites it.
|
|
36
|
+
def warn_redirect_uri_path_mismatch
|
|
37
|
+
value = configured_redirect_uri
|
|
38
|
+
# A callable callback_path matches requests itself, so there is no single path to compare with
|
|
39
|
+
return if value.nil? || options.callback_path.respond_to?(:call)
|
|
40
|
+
|
|
41
|
+
path = URI.parse(value).path
|
|
42
|
+
return if path.casecmp?(callback_path)
|
|
43
|
+
|
|
44
|
+
OmniauthOidc::Logging.warn("The redirect_uri path #{path} does not match the callback path " \
|
|
45
|
+
"#{callback_path} of the #{name} provider, so OmniAuth will not handle " \
|
|
46
|
+
"the provider's redirect. Set callback_path to #{path}.")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The README used to say redirect_uri could not be configured, so it may have been set here instead.
|
|
50
|
+
def warn_redirect_uri_in_extra_authorize_params
|
|
51
|
+
return unless options.extra_authorize_params.to_h.keys.any? { |key| key.to_s == "redirect_uri" }
|
|
52
|
+
|
|
53
|
+
OmniauthOidc::Logging.warn("redirect_uri in extra_authorize_params is ignored by the #{name} provider. " \
|
|
54
|
+
"Use the redirect_uri option instead.")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -6,20 +6,25 @@ module OmniAuth
|
|
|
6
6
|
# Code request phase
|
|
7
7
|
module Request
|
|
8
8
|
def request_phase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
OmniauthOidc::Logging.instrument("request_phase.start", provider: name) do
|
|
10
|
+
set_client_options_for_request_phase
|
|
11
|
+
warn_redirect_uri_path_mismatch
|
|
12
|
+
redirect authorize_uri
|
|
13
|
+
end
|
|
14
|
+
rescue OmniauthOidc::ConfigurationError => e
|
|
15
|
+
OmniauthOidc::Logging.error("Configuration error", error: e.class.name, message: e.message)
|
|
16
|
+
fail!(:configuration_error, e)
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def authorize_uri # rubocop:disable Metrics/AbcSize
|
|
17
|
-
client.redirect_uri = redirect_uri
|
|
18
20
|
opts = request_options
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
# OmniAuth stores option hashes with string keys. Keys are symbolized so that no param is sent twice:
|
|
23
|
+
# a configured param replaces the strategy's own value, and a request param never replaces either.
|
|
24
|
+
options.extra_authorize_params.each { |key, value| opts[key.to_sym] = value }
|
|
21
25
|
|
|
22
26
|
options.allow_authorize_params.each do |key|
|
|
27
|
+
key = key.to_sym
|
|
23
28
|
opts[key] = request.params[key.to_s] unless opts.key?(key)
|
|
24
29
|
end
|
|
25
30
|
|
|
@@ -27,10 +32,14 @@ module OmniAuth
|
|
|
27
32
|
verifier = options.pkce_verifier ? options.pkce_verifier.call : SecureRandom.hex(64)
|
|
28
33
|
|
|
29
34
|
opts.merge!(pkce_authorize_params(verifier))
|
|
30
|
-
session["
|
|
35
|
+
session[session_key("pkce.verifier")] = verifier
|
|
31
36
|
end
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
# Set last so neither extra_authorize_params nor request params can change it
|
|
39
|
+
opts[:redirect_uri] = redirect_uri
|
|
40
|
+
opts[:extra_params] = opts.compact
|
|
41
|
+
|
|
42
|
+
client.authorization_uri(opts)
|
|
34
43
|
end
|
|
35
44
|
|
|
36
45
|
private
|
|
@@ -45,7 +54,7 @@ module OmniAuth
|
|
|
45
54
|
ui_locales: params["ui_locales"],
|
|
46
55
|
claims_locales: params["claims_locales"],
|
|
47
56
|
prompt: options.prompt,
|
|
48
|
-
nonce: (new_nonce if
|
|
57
|
+
nonce: (new_nonce if nonce_required?),
|
|
49
58
|
hd: options.hd,
|
|
50
59
|
acr_values: options.acr_values
|
|
51
60
|
}
|
|
@@ -59,21 +68,20 @@ module OmniAuth
|
|
|
59
68
|
options.state.call
|
|
60
69
|
end
|
|
61
70
|
end
|
|
62
|
-
session["
|
|
71
|
+
session[session_key("state")] = state || SecureRandom.hex(16)
|
|
63
72
|
end
|
|
64
73
|
|
|
65
74
|
# Parse response from OIDC endpoint and set client options for request phase
|
|
66
|
-
def set_client_options_for_request_phase
|
|
75
|
+
def set_client_options_for_request_phase
|
|
67
76
|
client_options.host = host
|
|
68
|
-
client_options.authorization_endpoint =
|
|
69
|
-
client_options.token_endpoint =
|
|
70
|
-
client_options.userinfo_endpoint =
|
|
71
|
-
client_options.jwks_uri =
|
|
77
|
+
client_options.authorization_endpoint = config.authorization_endpoint
|
|
78
|
+
client_options.token_endpoint = config.token_endpoint
|
|
79
|
+
client_options.userinfo_endpoint = config.userinfo_endpoint
|
|
80
|
+
client_options.jwks_uri = config.jwks_uri
|
|
72
81
|
|
|
73
|
-
return unless config.
|
|
82
|
+
return unless config.end_session_endpoint
|
|
74
83
|
|
|
75
|
-
client_options.end_session_endpoint =
|
|
76
|
-
config.end_session_endpoint)
|
|
84
|
+
client_options.end_session_endpoint = config.end_session_endpoint
|
|
77
85
|
end
|
|
78
86
|
end
|
|
79
87
|
end
|