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

Add optional skip_issuer parameter to IdToken.verify! #98

Closed
Closed
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
4 changes: 2 additions & 2 deletions lib/openid_connect/response_object/id_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def initialize(attributes = {})
self.auth_time = auth_time.to_i unless auth_time.nil?
end

def verify!(expected = {})
def verify!(expected = {}, skip_issuer = false)
raise ExpiredToken.new('Invalid ID token: Expired token') unless exp.to_i > Time.now.to_i
raise InvalidIssuer.new('Invalid ID token: Issuer does not match') unless iss == expected[:issuer]
raise InvalidIssuer.new('Invalid ID token: Issuer does not match') unless (iss == expected[:issuer] || skip_issuer == true)
raise InvalidNonce.new('Invalid ID Token: Nonce does not match') unless nonce == expected[:nonce]

# aud(ience) can be a string or an array of strings
Expand Down
12 changes: 12 additions & 0 deletions spec/openid_connect/response_object/id_token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@
end
end

context 'when issuer is invalid and skip_issuer is set' do
it do
id_token.verify!(
{
issuer: 'some-issuer',
client_id: attributes[:aud],
},
true
).should == true
end
end

context 'when issuer is missing' do
it do
expect do
Expand Down