fix[faustwp-cli]: (#1850) detect HTTP Basic Auth and show accurate error#2316
Open
latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
Open
fix[faustwp-cli]: (#1850) detect HTTP Basic Auth and show accurate error#2316latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
Conversation
…urate error When a WordPress site is protected with HTTP Basic Authentication, the secret key validation request returns 401 from the web server, not from FaustWP. The health check assumed any 401 meant the secret key was wrong, showing a misleading error message. Check the WWW-Authenticate response header for "Basic" to distinguish HTTP Basic Auth (web server) from a secret key mismatch (plugin). Show a specific error message telling the user their site has Basic Auth protection. Closes wpengine#1850
|
Currently, we do not support the creation of preview deployments based on changes coming from forked repositories. |
🦋 Changeset detectedLatest commit: a175382 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a WordPress site is protected with HTTP Basic Authentication, the secret key validation request returns a 401 from the web server (Apache/Nginx), not from FaustWP. The health check assumed any 401 meant the secret key was wrong, showing a misleading error:
This PR checks the
WWW-Authenticateresponse header forBasicto distinguish between HTTP Basic Auth (web server blocking the request) and a genuine secret key mismatch (FaustWP rejecting the key). Each case now shows an accurate error message.Related Issues
Closes #1850
Testing
Confirm the issue (before the fix)
1. Verify the health check does not distinguish Basic Auth from secret key mismatch:
Confirm the fix
2. Verify the health check now checks WWW-Authenticate header:
3. Verify the new test case passes:
npx jest --config packages/faustwp-cli/jest.config.js --verbose -- validateFaustEnvVars # Expected: 6 tests pass, including "logs a Basic Auth error when the site returns 401 with WWW-Authenticate: Basic"4. Verify the existing 401 test still passes (secret key mismatch without Basic Auth):
npx jest --config packages/faustwp-cli/jest.config.js --verbose -- validateFaustEnvVars # Expected: "logs an error when the secret key validation fails" still passesRun the test suites
CLI tests:
Full JS tests: