def requires_rw(f):
    """ Adds readwrite authorization

        This will check if the user is a readonly user and if so reject the
        query. Apply this decorator to readwrite functions.
    """
    @wraps(f)

    def decorated(*args, **kwargs):
        auth = args[1]
        if auth.readonly:
            logger = logging.getLogger()
            logger.info("read-only user '%s' is not authorized to run function '%s'" % (auth.username, f.__name__))
            raise authlib.AuthorizationFailed("read-only user '%s' is not authorized to run function '%s'" % (auth.username, f.__name__))
        return f(*args, **kwargs)

    return decorated