Support » Plugin: Login by Auth0 » Migrating between environments – Auth0 Not Ready

  • Resolved ryansutherlandignite

    (@ryansutherlandignite)


    Hi,

    I have Auth0 up and running on a multisite. I am now setting up additional environments.

    – Production
    – Staging
    – Testing
    – Local

    Each environment will use the same settings and the process of creating each environments involves a full DB migration with minimal find/replace actions eg site url. This is pretty standard stuff.

    The problem

    I have been able to successfully get Auth0 working on a local and non local (testing) environment, however, I’ve noticed that when migrating the DB between environments (testing to local or the other way), Auth0 always prompts the Setup Wizard and does not respect the values already stored in the options table.

    Looking at the Plugin code, it appears to check if the options for domain, client_id and client_secret exist to deem Auth0 “ready”. This check appears to be failing, however, when looking in the options table, i can see the serialized values do indeed exist.

    public static function ready() {
    		$options = WP_Auth0_Options::Instance();
    		if ( ! $options->get( 'domain' ) || ! $options->get( 'client_id' ) || ! $options->get( 'client_secret' ) ) {
    			return false;
    		}
    		return true;
    	}

    As a result, each time I update the DB for my WP install on another environment, I need to go and re-add the Auth0 settings, and because its a multisite, I have to do this on many sites.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Josh C

    (@auth0josh)

    @ryansutherlandignite – Is it possible that your search/replace is breaking the serialization of that array? There are URLs in the settings and if they are replaced with a shorter or longer, that would corrupt what’s in there. Next migration, try pulling the setting out of the database with the core get_option() function, before anything loads. If it’s not pulling out the settings data, then there’s going wrong with the migration.

    That said … you can store settings using PHP constants instead of using the database:

    https://auth0.com/docs/cms/wordpress/configuration#php-constant-setting-storage

    That might help simplify things a bit.

    Thread Starter ryansutherlandignite

    (@ryansutherlandignite)

    Hi @auth0josh – Yep you are right, its to do with the serialization.

    Its because the default login redirection setting appears to be auto populated with the site url. I tried removing it so that I can rely on the constant instead, however, it appears that even with AUTH0_ENV_DEFAULT_LOGIN_REDIRECTION defined, the setting is still stored in the db.

    As such, when I do my find and replace for the site url eg production.mysite.com to local.mysite.com, it updates the serialized value and then fails.

    Have you got any suggestions?

    Plugin Contributor Josh C

    (@auth0josh)

    The value in the database is kept, even if the constant is set, until you save the settings. So set the constant on the “from” site and then save the Auth0 settings. Now you should be able to migrate and set the constant on the new site. Going forward, that value won’t be in the settings so you shouldn’t have a problem.

    Thread Starter ryansutherlandignite

    (@ryansutherlandignite)

    Hi Josh,

    Great! Thanks this works

    Thread Starter ryansutherlandignite

    (@ryansutherlandignite)

    Hey Josh,

    I understand this ticket is resolved, however, got a related question.

    We are running a multisite. We’ve used the PHP constant AUTH0_ENV_DEFAULT_LOGIN_REDIRECTION to help get passed the issue of serialized data changes when migrating between environments, however, naturally the default login redirection url should be different for each site on the multisite. eg multisite.com/site2/ and multisite.com/site3/ etc

    Each site will actually have a unique auth0 application.

    My guess is I will need to look into a way to import/export our db between environments in a manner that handles serialized data… potentially via the WP CLI…

    Before I go down this path, do you have any other suggestions? My guess is we are not the first customers to run a multisite using auth0

    Plugin Contributor Josh C

    (@auth0josh)

    Definitely not the first, no 🙂 There are a few different ways to set it up with the plugin, detailed here:

    https://auth0.com/docs/cms/wordpress/installation#multisite-setup

    In your case, those constants won’t work well for values that need to be different. We’ve discussed enhancing the constant settings to take mutli-site setups like your into account but haven’t moved forward with anything there.

    I would imagine if you’re migrating from, say, dev to staging, the domains are different and need to be updated throughout the site database, correct? WP CLI is a great tool for that and would pick up that change in the Auth0 plugin settings.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Migrating between environments – Auth0 Not Ready’ is closed to new replies.