Exemplo n.º 1
0
    required_claims = app.config['JWT_REQUIRED_CLAIMS']

    options = {'verify_' + claim: True for claim in verify_claims}

    options.update({'require_' + claim: True for claim in required_claims})

    return jwt.decode(token,
                      secret,
                      options=options,
                      algorithms=[algorithm],
                      leeway=leeway,
                      audience=app.config['RESOURCE_ID'])


_jwt = JWT(app, authenticate, identity)
_jwt.jwt_decode_callback = _jwt_decode_callback


def has_client_authoritie(authority):
    """View decorator that requires a valid JWT token to be present in the request

    :param realm: an optional realm
    """
    def wrapper(fn):
        @wraps(fn)
        def decorator(*args, **kwargs):
            authorities = current_identity['user_client_authorities']
            print(authority)
            if authority in authorities:
                print(authorities)
            else:
Exemplo n.º 2
0
    required_claims = app.config['JWT_REQUIRED_CLAIMS']

    options = {
        'verify_' + claim: True
        for claim in verify_claims
    }

    options.update({
        'require_' + claim: True
        for claim in required_claims
    })

    return jwt.decode(token, secret, options=options, algorithms=[algorithm], leeway=leeway , audience =  app.config['RESOURCE_ID'] )

_jwt = JWT(app , authenticate , identity )
_jwt.jwt_decode_callback = _jwt_decode_callback


def has_client_authoritie(authority):
    """View decorator that requires a valid JWT token to be present in the request

    :param realm: an optional realm
    """
    def wrapper(fn):
        @wraps(fn)
        def decorator(*args, **kwargs):
            authorities = current_identity['user_client_authorities']
            print( authority )
            if authority in authorities:
              print( authorities )
            else: