Class: OpenID::Store::Memcache

Inherits:
Object
  • Object
show all
Defined in:
lib/openid_dalli_store.rb

Instance Method Summary collapse

Instance Method Details

#use_nonce(server_url, timestamp, salt) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/openid_dalli_store.rb', line 7

def use_nonce(server_url, timestamp, salt)
  return false if (timestamp - Time.now.to_i).abs > Nonce.skew
  ts = timestamp.to_s # base 10 seconds since epoch
  nonce_key = key_prefix + 'N' + server_url + '|' + ts + '|' + salt
  result = @cache_client.add(nonce_key, '', expiry(Nonce.skew + 5))
  if result.is_a? String
    return !!(result =~ /^STORED/)
  else
    return result == true
  end
end