def auth_required(decorated_fn=None, **role_rules):
    required_roles = []
    one_of_roles = []
    if not (decorated_fn and callable(decorated_fn)):
        if 'role' in role_rules and 'roles' in role_rules:
            raise RuntimeError('specify only one of `role` or `roles` kwargs')
        elif 'role' in role_rules:
            required_roles = [role_rules['role']]
        elif 'roles' in role_rules:
            required_roles = role_rules['roles']
        if 'one_of' in role_rules:
            one_of_roles = role_rules['one_of']
    def wrapper(fn):
        @wraps(fn)
        @_auth_required()
        @roles_required(*required_roles)
        @roles_accepted(*one_of_roles)
        def decorated(*args, **kwargs):
            return fn(*args, **kwargs)
        return decorated
    if decorated_fn and callable(decorated_fn):
        return wrapper(decorated_fn)
    return wrapper