lib/fernet/verifier.rb in fernet-1.4 vs lib/fernet/verifier.rb in fernet-1.5
- old
+ new
@@ -1,7 +1,6 @@
require 'base64'
-require 'yajl'
require 'openssl'
require 'date'
module Fernet
class Verifier
@@ -42,22 +41,23 @@
def deconstruct
parts = @token.split('|')
if decrypt?
encrypted_data, iv, @received_signature = *parts
- @data = Yajl::Parser.parse(decrypt!(encrypted_data, Base64.urlsafe_decode64(iv)))
+ @data = Fernet::OkJson.decode(decrypt!(encrypted_data, Base64.urlsafe_decode64(iv)))
signing_blob = "#{encrypted_data}|#{iv}"
else
encoded_data, @received_signature = *parts
signing_blob = encoded_data
- @data = Yajl::Parser.parse(Base64.urlsafe_decode64(encoded_data))
+ @data = Fernet::OkJson.decode(Base64.urlsafe_decode64(encoded_data))
end
@regenerated_mac = OpenSSL::HMAC.hexdigest('sha256', signing_blob, signing_key)
end
def token_recent_enough?
if enforce_ttl?
- DateTime.parse(data['issued_at']) > (now - ttl)
+ good_till = DateTime.parse(data['issued_at']) + (ttl.to_f / 24 / 60 / 60)
+ good_till > now
else
true
end
end