示例#1
0
文件: auth.py 项目: websuslik/ws-rest
 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
文件: db.py 项目: websuslik/ws-rest
 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
文件: db.py 项目: websuslik/ws-rest
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')