lib/jwt_easy/decoder.rb in jwt_easy-0.1.0 vs lib/jwt_easy/decoder.rb in jwt_easy-0.2.0

- old
+ new

@@ -40,16 +40,31 @@ # # @return [Hash] the headers to be used def headers @headers.tap do |headers| headers[:algorithm] = configuration.algorithm if verification? - case configuration.claim when CLAIM_EXPIRATION_TIME - headers[:validate_exp] = true + headers.merge!(exp_headers) when CLAIM_NOT_BEFORE_TIME - headers[:validate_nbf] = true + headers.merge!(nbf_headers) end + end + end + + private + + def exp_headers + {}.tap do |headers| + headers[:validate_exp] = true + headers[:exp_leeway] = configuration.leeway if configuration.leeway + end + end + + def nbf_headers + {}.tap do |headers| + headers[:validate_nbf] = true + headers[:nbf_leeway] = configuration.leeway if configuration.leeway end end end end