Class: AppIdentity::Versions::TimestampNonce

Inherits:
Base
  • Object
show all
Defined in:
lib/app_identity/versions.rb

Overview

:nodoc:

Direct Known Subclasses

V2, V3, V4

Instance Method Summary collapse

Methods inherited from Base

defined, inherited, #inspect, instance, #make_digest

Instance Method Details

#check_nonce!(nonce, config) ⇒ Object

:nodoc:

Raises:



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/app_identity/versions.rb', line 77

def check_nonce!(nonce, config) # :nodoc:
  super(nonce, config)

  timestamp = parse_timestamp!(nonce)
  config ||= default_config
  fuzz = config[:fuzz] || config["fuzz"] || 600

  diff = (Time.now.utc - timestamp).abs.to_i

  raise AppIdentity::Error, "nonce is invalid" unless diff <= fuzz
end

#generate_nonceObject

:nodoc:



73
74
75
# File 'lib/app_identity/versions.rb', line 73

def generate_nonce # :nodoc:
  Time.now.utc.strftime("%Y%m%dT%H%M%S.%6NZ")
end

#nonce_typeObject

:nodoc:



69
70
71
# File 'lib/app_identity/versions.rb', line 69

def nonce_type # :nodoc:
  :timestamp
end