Class: Sworn::ReplayProtector::Redis
- Inherits:
-
Object
- Object
- Sworn::ReplayProtector::Redis
- Defined in:
- lib/sworn/replay_protector/redis.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ Redis
constructor
A new instance of Redis.
- #replayed?(oauth) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Redis
Returns a new instance of Redis.
4 5 6 7 |
# File 'lib/sworn/replay_protector/redis.rb', line 4 def initialize(*args) , _ = args.flatten @connection = .fetch(:redis_connection) end |
Instance Method Details
#replayed?(oauth) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/sworn/replay_protector/redis.rb', line 9 def replayed?(oauth) key = nonce_key(oauth) return true if @connection.exists(key) @connection.setex(key, Sworn.configuration.max_drift, 1) false end |