Skip to content

Commit bc6932e

Browse files
committed
Don't call #to_h on session in callback
**Why**: The rack session object does not respond to that method in some versions
1 parent 9bc87ea commit bc6932e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/omniauth/login_dot_gov/callback.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Callback
44
attr_reader :session, :client, :id_token, :userinfo
55

66
def initialize(session:, client:)
7-
@session = session.to_h
7+
@session = session
88
@client = client
99
end
1010

@@ -15,7 +15,7 @@ def call(params)
1515
code: params['code'],
1616
client: client
1717
).request_id_token
18-
id_token.verify_nonce(session.dig('oidc', 'nonce_digest'))
18+
id_token.verify_nonce(get_oidc_value_from_session('nonce_digest'))
1919
@userinfo = UserinfoRequest.new(
2020
id_token: id_token,
2121
client: client
@@ -29,7 +29,7 @@ def verify_state(params)
2929
cb_state_digest = OpenSSL::Digest::SHA256.base64digest(cb_state)
3030
return if SecureCompare.compare(
3131
cb_state_digest,
32-
session.dig('oidc', 'state_digest')
32+
get_oidc_value_from_session('state_digest')
3333
)
3434
raise CallbackStateMismatchError
3535
end
@@ -45,6 +45,12 @@ def handle_error(params)
4545
end
4646
raise error_type, params['error_description']
4747
end
48+
49+
def get_oidc_value_from_session(key)
50+
oidc_session = session['oidc']
51+
return if oidc_session.nil?
52+
oidc_session[key]
53+
end
4854
end
4955
end
5056
end

0 commit comments

Comments
 (0)