fix(bootstrap): normalize auth header sources and harden Basic credential extraction in handleAuthHeaders#60885
Draft
joshtrichards wants to merge 1 commit into
Draft
fix(bootstrap): normalize auth header sources and harden Basic credential extraction in handleAuthHeaders#60885joshtrichards wants to merge 1 commit into
handleAuthHeaders#60885joshtrichards wants to merge 1 commit into
Conversation
…ders() Signed-off-by: Josh <josh.t.richards@gmail.com>
OC::handleAuthHeadersOC::handleAuthHeaders
OC::handleAuthHeadershandleAuthHeaders
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.
Summary
Rewrites
OC::handleAuthHeaders()to consolidate the previously two-pass auth header normalization into a single, clearly-prioritized approach, and hardens Basic credential extraction.What changed
Before: Two separate concerns were handled sequentially:
HTTP_XAUTHORIZATION→HTTP_AUTHORIZATIONif the latter was missing (FastCGI workaround)HTTP_AUTHORIZATIONandREDIRECT_HTTP_AUTHORIZATIONto extract PHP Basic auth credentialsAfter: A single pass with an explicit priority chain:
The resolved value is normalized into
HTTP_AUTHORIZATION, then Basic credentials are extracted once if present.Additional improvements
base64_decode(..., true)(strict mode) to reject malformed Base64 instead of silently mangling itpreg_match+countwithstripos+str_containsfor cleaner, more readable logicIRequest, web server requirements)Behavioral notes
REDIRECT_HTTP_AUTHORIZATIONnow takes priority overHTTP_XAUTHORIZATIONwhenHTTP_AUTHORIZATIONis absent. PreviouslyHTTP_XAUTHORIZATIONwas copied first and thus took priority... mostly. But thenREDIRECT_HTTP_AUTHORIZATIONwas consulting for setting thePHP_USER_*values. The new order is more semantically correct (REDIRECT_*is an Apache-native redirect;HTTP_XAUTHORIZATIONis a FastCGI-specific workaround).Basic), per RFC 7617 §2. Non-conformant clients sendingBasic\tor multiple spaces will no longer have credentials extracted (they were silently accepted before). Also better matches what we do elsewhere anyhow.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)