Exemple #1
0
 def _delete_keys(self, user_id, token_id):
     pipe = self.conn.pipeline()
     token_key = keys.token(token_id)
     pipe.delete(token_key, )
     if user_id is not None:
         user_key = keys.usertoken(user_id['id'], token_id)
         pipe.delete(user_key, )
     pipe.sadd(keys.revoked(), token_id)
     return pipe.execute()[0]
Exemple #2
0
 def get_token(self, token_id):
     token_key = keys.token(token_id)
     value = self.readonly.get(token_key)
     if value:
         token = jsonutils.loads(value)
         if token.get('expires', None) is not None:
             token['expires'] = dateutil.parser.parse(token['expires'])
             if token['expires'] > timeutils.utcnow():
                 return token
         else:
             return token
     raise exception.TokenNotFound(token_id=token_id)
Exemple #3
0
 def _set_keys(self, user_id, token_id, json_data, ttl_seconds):
     pipe = self.conn.pipeline()
     token_key = keys.token(token_id)
     if user_id:
         user_key = keys.usertoken(user_id['id'], token_id)
     if ttl_seconds is None:
         pipe.set(token_key, json_data)
         if user_id:
             pipe.set(user_key, '')
     else:
         pipe.setex(token_key, json_data, ttl_seconds)
         if user_id:
             pipe.setex(user_key, '', ttl_seconds)
     pipe.execute()