noop
            ret = authzero.create_client(r)
            logger.info("New remote client {} ({}) created on Auth0".format(
                ret.get('client_id'), ret.get('name')))
        else:
            rclient = find_client_by_id(remote_clients, lclient.client_id)
            if (rclient == lclient):
                logger.debug(
                    "Remote and local clients for id {} ({}) are identical, no need to "
                    "update".format(lclient.client_id, lclient.name))
                continue

            # Show pretty informational unified diff if requested, of the changes to be pushed to Auth0
            if args.show_diff:
                diff = difflib.unified_diff(
                    json.dumps(rclient, indent=4).split('\n'),
                    json.dumps(lclient, indent=4).split('\n'),
                    fromfile="previous_{}.json".format(lclient.client_id),
                    tofile="new_{}.json".format(lclient.client_id))
                print("Unified diff for client {} ({})".format(
                    lclient.client_id, lclient.name))
                print('\n'.join(diff))

            logger.debug("Updating remote client {} ({}) on Auth0".format(
                lclient.name, lclient.client_id))
            authzero.update_client(lclient.client_id, lclient)
            logger.info("Client {} ({}) has been updated on Auth0".format(
                client.name, lclient.client_id))

    sys.exit(0)
示例#2
0
    parser.add_argument('-s',
                        '--clientsecret',
                        default=credentials.client_secret,
                        required=require_creds,
                        help='Auth0 client secret')
    parser.add_argument(
        '--default-client',
        default='VNGM4quJw3Nhx28j8XKVYmu5LcPMCgAH',
        help='Default Auth0 client id, needed for login page for example')
    parser.add_argument('--login-page',
                        required=True,
                        help='Auth0 hosted login page (HTML)')
    args = parser.parse_args()

    config = DotDict({
        'client_id': args.clientid,
        'client_secret': args.clientsecret,
        'uri': args.uri
    })
    authzero = AuthZero(config)
    authzero.get_access_token()
    logger.debug("Got access token for client_id:{}".format(args.clientid))

    client_attributes = DotDict(dict())
    with open(args.login_page, 'r', encoding='utf-8') as fd:
        client_attributes.custom_login_page = fd.read()
    # on any error, `authzero` will raise an exception and python will exit with non-zero code
    ret = authzero.update_client(args.default_client, client_attributes)
    logger.debug("Default client updated {}".format(json.dumps(ret)))
    sys.exit(0)