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())
def __init__(self): self.client = pymongo.MongoClient(cfg.get('DB_MONGO_URI')) self.backend = self.client[cfg.get('DB_MONGO_DATABASE')]
def token_decode(data): return jwt.decode(data, cfg.get('SECRET'), algorithms=['HS256'])
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)
def token_encode(data): return jwt.encode(data, cfg.get('SECRET'), algorithm='HS256').decode('utf-8')