Skip to content

Commit

Permalink
bugfix: NoMethodError (undefined method `count' for #<OpenIDConnect::…
Browse files Browse the repository at this point in the history
…ResponseObject::IdToken:0x0000000008d9dde0>): (jjbohn#60)

since id_token gets decoded twice

fix jjbohn#59
  • Loading branch information
ignatiusreza authored May 25, 2020
1 parent b2f5f71 commit 6398ad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/omniauth/strategies/openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def access_token
client_auth_method: options.client_auth_method
)

verify_id_token!(decode_id_token(@access_token.id_token)) if configured_response_type == 'code'
verify_id_token!(@access_token.id_token) if configured_response_type == 'code'

@access_token
end
Expand Down Expand Up @@ -330,6 +330,8 @@ def configured_response_type
end

def verify_id_token!(id_token)
return unless id_token

decode_id_token(id_token).verify!(issuer: options.issuer,
client_id: client_options.identifier,
nonce: stored_nonce)
Expand Down
2 changes: 1 addition & 1 deletion test/lib/omniauth/strategies/openid_connect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def test_callback_phase(session = {}, params = {})
id_token = stub('OpenIDConnect::ResponseObject::IdToken')
id_token.stubs(:raw_attributes).returns('sub' => 'sub', 'name' => 'name', 'email' => 'email')
id_token.stubs(:verify!).with(issuer: strategy.options.issuer, client_id: @identifier, nonce: nonce).returns(true)
::OpenIDConnect::ResponseObject::IdToken.stubs(:decode).returns(id_token)
id_token.expects(:verify!)

strategy.expects(:decode_id_token).with(access_token.id_token).returns(id_token)
strategy.call!('rack.session' => { 'omniauth.state' => state, 'omniauth.nonce' => nonce })
strategy.callback_phase
end
Expand Down

0 comments on commit 6398ad1

Please sign in to comment.