Class: Auth::ClientCredentials::AccessTokenTracker
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- Auth::ClientCredentials::AccessTokenTracker
- Defined in:
- lib/lighthouse/auth/client_credentials/access_token_tracker.rb
Constant Summary collapse
- TOLERANCE =
5
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Class Method Summary collapse
- .get_access_token(service_name) ⇒ Object
- .set_access_token(service_name, access_token, ttl = redis_namespace_ttl) ⇒ Object
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Class Method Details
.get_access_token(service_name) ⇒ Object
30 31 32 33 |
# File 'lib/lighthouse/auth/client_credentials/access_token_tracker.rb', line 30 def self.get_access_token(service_name) service = find(service_name) service&.access_token end |
.set_access_token(service_name, access_token, ttl = redis_namespace_ttl) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lighthouse/auth/client_credentials/access_token_tracker.rb', line 19 def self.set_access_token(service_name, access_token, ttl = redis_namespace_ttl) service = new(service_name:) service.access_token = access_token service.save! # We want to set the TTL dynamically # Using TOLERANCE here so that we can avoid using the access_token right as # it is expiring service.expire(ttl - TOLERANCE) end |