Пример #1
0
 def init_app(self, app):
     if cfg.get('SECRET') is None:
         raise ValueError('SECRET is not provided')
     self.app = app
     self._create_user_resources()
     self.app.add_middleware(CurrentUser())
Пример #2
0
 def __init__(self):
     self.client = pymongo.MongoClient(cfg.get('DB_MONGO_URI'))
     self.backend = self.client[cfg.get('DB_MONGO_DATABASE')]
Пример #3
0
def token_decode(data):
    return jwt.decode(data, cfg.get('SECRET'), algorithms=['HS256'])
Пример #4
0
def marshal(data, db, max_depth=None):
    if max_depth is None:
        max_depth = cfg.get('MAX_DEPTH', 1)
    return MongoMarshal(db, max_depth).marshal(data)
Пример #5
0
def token_encode(data):
    return jwt.encode(data, cfg.get('SECRET'), algorithm='HS256').decode('utf-8')