示例#1
0
        for rr in remote_rules:
            if (rl.id == rr.get('id')) or (rl.is_new):
                ok = True
                continue
        if not ok and rr is not None:
            remove_rules.append(rr)
    logger.debug(
        "Found {} rules that not longer exist locally and will be deleted remotely"
        .format(len(remove_rules)))

    # Update or create (or delete) rules as needed
    ## Delete first in case we need to get some order numbers free'd
    for r in remove_rules:
        logger.debug("[-] Removing rule {} ({}) from Auth0".format(
            r.name, r.id))
        authzero.delete_rule(r.id)

    ## Update & Create (I believe this may be atomic swaps for updates)
    for r in local_rules:
        if r.is_new:
            logger.debug("[+] Creating new rule {} on Auth0".format(r.name))
            ret = authzero.create_rule(r)
            logger.debug("+ New rule created with id {}".format(ret.get('id')))
        elif r.is_the_same:
            logger.debug("[=] Rule {} is unchanged, will no update".format(
                r.name))
        else:
            logger.debug("[~] Updating rule {} ({}) on Auth0".format(
                r.name, r.id))
            authzero.update_rule(r.id, r)
示例#2
0
        for rr in remote_rules:
            if (rl.id == rr.get('id')) or (rl.is_new):
                ok = True
                continue
        if not ok and rr is not None:
            remove_rules.append(rr)
    logger.debug(
        "Found {} rules that not longer exist locally and will be deleted remotely"
        .format(len(remove_rules)))

    # Update or create (or delete) rules as needed
    ## Delete first in case we need to get some order numbers free'd
    for r in remove_rules:
        logger.debug("[-] {}Removing rule {} ({}) from Auth0".format(
            dry_run_message, r.name, r.id))
        not args.dry_run and authzero.delete_rule(r.id)

    ## Update & Create (I believe this may be atomic swaps for updates)
    for r in local_rules:
        if r.is_new:
            logger.debug("[+] {}Creating new rule {} on Auth0".format(
                dry_run_message, r.name))
            if not args.dry_run:
                ret = authzero.create_rule(r)
                logger.debug("+ New rule created with id {}".format(
                    ret.get('id')))
        elif r.is_the_same:
            logger.debug("[=] Rule {} is unchanged, will not update".format(
                r.name))
        else:
            logger.debug("[~] {}Updating rule {} ({}) on Auth0".format(
示例#3
0
    maintenance_rule = next(
        x for x in local_rules if x.name == MAINTENANCE_RULE_NAME)
    if args.delete_all_rules_first_causing_outage:
        maintenance_rule.enabled = True
        logger.debug("[+] {}Enabling maintenance rule denying all logins globally {} {}".format(
            dry_run_message, maintenance_rule.name, maintenance_rule.id))
        if not args.dry_run:
            authzero.update_rule(maintenance_rule.id, maintenance_rule)

    # Update or create (or delete) rules as needed
    ## Delete first in case we need to get some order numbers free'd
    for rule in rules_to_remove:
        logger.debug("[-] {}Removing rule {} ({}) from Auth0".format(
            dry_run_message, rule['name'], rule['id']))
        if not args.dry_run:
            authzero.delete_rule(rule['id'])

    ## Update & Create (I believe this may be atomic swaps for updates)
    for local_rule in local_rules:
        if local_rule.is_new:
            if args.delete_all_rules_first_causing_outage and local_rule.name == MAINTENANCE_RULE_NAME:
                continue
            logger.debug("[+] {}Creating new rule {} on Auth0".format(
                dry_run_message, local_rule.name))
            if not args.dry_run:
                result = authzero.create_rule(local_rule)
                logger.debug("+ New rule created with id {}".format(result.get('id')))
        elif local_rule.is_the_same:
            logger.debug("[=] Rule {} is unchanged, will not update".format(local_rule.name))
        else:
            logger.debug("[~] {}Updating rule {} ({}) on Auth0".format(