def roles_required(*required_rolenames):
    """
    This decorator ensures that any uses accessing the decorated route have all
    the needed roles to access it. If an @auth_required decorator is not
    supplied already, this decorator will implicitly check @auth_required first
    """
    def decorator(method):
        @functools.wraps(method)
        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: {}",
                    [', '.join(role_set)],
                )
                return method(*args, **kwargs)
            finally:
                remove_jwt_data_from_app_context()
        return wrapper
    return decorator