Skip to content

Commit

Permalink
Merge pull request #257 from ab320012/master
Browse files Browse the repository at this point in the history
Removed leeway from verify_iat
  • Loading branch information
excpt authored Mar 22, 2018
2 parents c6643e3 + 22b24f0 commit dba5c9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/jwt/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def verify_iat
return unless @payload.include?('iat')

iat = @payload['iat']
raise(JWT::InvalidIatError, 'Invalid iat') if !iat.is_a?(Numeric) || iat.to_f > (Time.now.to_f + iat_leeway)
raise(JWT::InvalidIatError, 'Invalid iat') if !iat.is_a?(Numeric) || iat.to_f > Time.now.to_f
end

def verify_iss
Expand Down
9 changes: 3 additions & 6 deletions spec/jwt/verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@ module JWT
Verify.verify_iat(payload, options)
end

it 'must allow configured leeway' do
Verify.verify_iat(payload.merge('iat' => (iat + 60)), options.merge(leeway: 70))
end

it 'must allow configured iat_leeway' do
Verify.verify_iat(payload.merge('iat' => (iat + 60)), options.merge(iat_leeway: 70))
it 'must ignore configured leeway' do
expect{Verify.verify_iat(payload.merge('iat' => (iat + 60)), options.merge(leeway: 70)) }
.to raise_error(JWT::InvalidIatError)
end

it 'must properly handle integer times' do
Expand Down

0 comments on commit dba5c9b

Please sign in to comment.