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

Log missing kid when ID token verification fails #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion lib/omniauth/strategies/openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ def decode_id_token(id_token)
# done. However, if there is no kid, then we try each key
# individually to see if one works:
# https://github.com/nov/json-jwt/pull/92#issuecomment-824654949
raise if decoded&.header&.key?('kid')
if decoded&.header&.key?('kid')
kid = decoded.header['kid']
raise JSON::JWK::Set::KidNotFound, "kid '#{kid}' not found"
end

decoded = decode_with_each_key!(id_token, keyset)

Expand Down
4 changes: 3 additions & 1 deletion test/lib/omniauth/strategies/openid_connect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ def test_callback_phase_with_id_token_with_kid_and_no_matching_kid
strategy.unstub(:user_info)
strategy.call!('rack.session' => { 'omniauth.state' => state, 'omniauth.nonce' => nonce })

assert_raises JSON::JWK::Set::KidNotFound do
error = assert_raises JSON::JWK::Set::KidNotFound do
strategy.callback_phase
end

assert_match %r{kid '.*' not found}, error.message
end

def test_callback_phase_with_id_token_with_hs256
Expand Down
Loading