Add ability to detect config overrides and invalidate token

Created on 6 August 2019, over 5 years ago
Updated 3 April 2024, 8 months ago

In SalesforceAuthProviderPluginManager, both updateAuthConfig and getAuthConfig use configFactory()->getEditable rather than configFactory()->get(). This is fine if you're not overriding the authentication settings in a settings.php. If you are, however, the values from the config form rather than your settings file will be used in seeking to reauthenticate, leaving you stuck.

The patch I'll attach after creating this issue modifies these 2 functions so they use get() rather than getEditable, allowing the user to get themselves back into a usable state.

Steps to reproduce (I think I have this right - I had trouble reproducing the issue after running through the fix the first time):
1. Get a database that is already authenticated with a different token to the one you want to use (eg download a production database).
2. In a settings.php file, override the salesforce.settings keys:

   $config['salesforce.settings']['consumer_key'] = '<key>';
   $config['salesforce.settings']['consumer_secret'] = '<secret>';
   $config['salesforce.settings']['login_url'] = '<login_url>';

3. Visit /admin/config/salesforce/authorize. You'll see the error message "Salesforce identity does not match salesforce endpoint: you need to re-authenticate.". This appears because the key and secret don't match the auth token you were using.
4. Submit the form to get Drupal to attempt to reauthorise. It should use the overridden settings, but it will actually use the form settings. This won't fix the issue and you'll be returned to step 3.
5. Apply the patch and resubmit the form. This time you'll be able to provide your site with access and start using the configuration from your overridden settings.

(If you have an IDE and set a breakpoint at line 75 of SalesforceAuthProviderPluginManager.php, you'll see it saving the form values without the patch, and the overridden settings with it applied).

✨ Feature request
Status

Needs review

Version

5.0

Component

salesforce.module

Created by

πŸ‡¦πŸ‡ΊAustralia nigelcunningham Geelong

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024