Esempio n. 1
0
 def wrapper(*args, **kwargs):
     MissingRoleError.require_condition(
         not current_rolenames().isdisjoint(set(accepted_rolenames)),
         "This endpoint requires one of the following roles: {}",
         [', '.join(accepted_rolenames)],
     )
     return method(*args, **kwargs)
Esempio n. 2
0
 def wrapper(*args, **kwargs):
     MissingRoleError.require_condition(
         current_rolenames().issuperset(set(required_rolenames)),
         "This endpoint requires all the following roles: {}",
         [', '.join(required_rolenames)],
     )
     return method(*args, **kwargs)
Esempio n. 3
0
 def wrapper(*args, **kwargs):
     _verify_and_add_jwt()
     try:
         MissingRoleError.require_condition(
             current_rolenames().issuperset(set(required_rolenames)),
             "This endpoint requires all the following roles: {}",
             [', '.join(required_rolenames)],
         )
         return method(*args, **kwargs)
     finally:
         remove_jwt_data_from_app_context()
Esempio n. 4
0
 def wrapper(*args, **kwargs):
     role_set = set([str(n) for n in accepted_rolenames])
     _verify_and_add_jwt()
     try:
         MissingRoleError.require_condition(
             not current_rolenames().isdisjoint(role_set),
             "This endpoint requires one of the following roles: {}",
             [', '.join(role_set)],
         )
         return method(*args, **kwargs)
     finally:
         remove_jwt_data_from_app_context()
Esempio n. 5
0
 def wrapper(*args, **kwargs):
     role_set = set([str(n) for n in required_rolenames])
     _verify_and_add_jwt()
     try:
         MissingRoleError.require_condition(
             current_rolenames().issuperset(role_set),
             "This endpoint requires all the following roles: "
             "{}".format([', '.join(role_set)]),
         )
         return method(*args, **kwargs)
     finally:
         remove_jwt_data_from_app_context()
Esempio n. 6
0
        def wrapper(*args, **kwargs):
            verify_user_session()
            meta = Meta.query.get(session["profile"]["meta_id"])
            role_set = set([str(n) for n in required_rolenames])
            user_roles = set(r.strip() for r in meta.roles.split(','))

            try:
                MissingRoleError.require_condition(
                    user_roles.issuperset(role_set),
                    "This endpoint requires all the following roles: {}",
                    [', '.join(role_set)],
                )
                return f(*args, **kwargs)
            finally:
                print("Role requirement complete")
Esempio n. 7
0
 def wrapper(*args, **kwargs):
     PraetorianError.require_condition(
         not current_guard().roles_disabled,
         "This feature is not available because roles are disabled",
     )
     role_set = set([str(n) for n in required_rolenames])
     _verify_and_add_jwt()
     try:
         MissingRoleError.require_condition(
             current_rolenames().issuperset(role_set),
             "This endpoint requires all the following roles: "
             "{}".format([", ".join(role_set)]),
         )
         return method(*args, **kwargs)
     finally:
         remove_jwt_data_from_app_context()