def test_ajwt_authorize_v2(): ver2 = ajwt.decode(getenv('AJWT_KEY_V2'), privkey=privKey, pubkey=pubKey, algorithms=['RS256']) print(ajwt.authorize(ver2, roles=['msgxc_admin'])) assert None != ver2
def test_ajwt_v2(): ver2 = ajwt.decode(getenv('AJWT_KEY_V2'), privkey=privKey, pubkey=pubKey, algorithms=['RS256']) print(ver2) assert None != ver2
def auth(req, roles=[], rights=[], tags=[]): token = req.cookies.get(getenv('CLIENT_AUTH_COOKIE')) if token == None: token = (request.headers["Authorization"] if "Authorization" in request.headers else None) if token == None: try: data = request.get_json(force=True) token = data.get(getenv('CLIENT_AUTH_COOKIE')) if token == None: token = data.get('ajwt') except: pass if token == None or len(token) == 0: raise Exception('bad token') token = token.replace('Bearer ', '', 1) token = ajwt.decode(token, privkey=privKey, pubkey=pubKey, secret=secret, algorithms=['HS256', 'RS256']) return token, ajwt.authorize(token, roles=roles, rights=rights, tags=tags)
def test_ajwt_authorize_v1(): ver1 = ajwt.decode(getenv('AJWT_KEY_V1'), secret=getenv('APP_SECRET'), algorithms=['HS256']) print(ajwt.authorize(ver1, tags=['admin'])) assert None != ver1
def test_ajwt_v1(): ver1 = ajwt.decode(getenv('AJWT_KEY_V1'), secret=getenv('APP_SECRET'), algorithms=['HS256']) print(ver1) assert None != ver1