Skip to content

Commit

Permalink
Merge pull request #161 from excpt/issue-157
Browse files Browse the repository at this point in the history
Fix: exp claim check
  • Loading branch information
excpt authored Aug 23, 2016
2 parents 8600e30 + 405671e commit 732729a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jwt/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def verify_aud
def verify_expiration
return unless @payload.include?('exp')

if @payload['exp'].to_i < (Time.now.to_i - leeway)
if @payload['exp'].to_i <= (Time.now.to_i - leeway)
fail(JWT::ExpiredSignature, 'Signature has expired')
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/jwt/verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ module JWT
it 'must allow some leeway in the expiration when configured' do
Verify.verify_expiration(payload, options.merge(leeway: 10))
end

it 'must be expired if the exp claim equals the current time' do
payload.merge!('exp' => Time.now.to_i)

expect do
Verify.verify_expiration(payload, options)
end.to raise_error JWT::ExpiredSignature
end
end

context '.verify_iat(payload, options)' do
Expand Down

0 comments on commit 732729a

Please sign in to comment.