Repository navigation
fix(auth): authenticate after same-host HTTPS upgrades - #1663
Merged
TerryHowe merged 1 commit intoOct 22, 2026
Merged
Conversation
Retry the upgraded HTTPS endpoint after its authentication challenge. Check every redirect hop and keep upgraded credentials out of the cache so later HTTP requests do not reuse them. Fixes oras-project#1245 Signed-off-by: Yash2017 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1663 +/- ##
==========================================
+ Coverage 92.65% 92.67% +0.02%
==========================================
Files 112 112
Lines 9307 9335 +28
==========================================
+ Hits 8623 8651 +28
Misses 674 674
Partials 10 10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TerryHowe
marked this pull request as ready for review
October 22, 2026 10:15
TerryHowe
requested review from
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
October 22, 2026 10:15
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.
Fixes #1245
auth.Clientcan authenticate after a same-host HTTP-to-HTTPS redirect on the standard ports (80 to 443). It retries the HTTPS endpoint directly and preserves the redirected method and body.The origin check rejected the HTTPS challenge because the scheme changed. The retry also started from the original HTTP URL.
The exception checks every redirect hop. Host, nonstandard port, and repository changes still block authentication, as do HTTPS downgrades. Redirects still strip
Authorization. Bearer realm validation uses the HTTPS URL.Credentials obtained after an upgrade are not cached. The cache keys omit the scheme, so caching them could send them over HTTP on a later request. This costs another authentication exchange for each upgrade.
Before / after
The regression tests use local HTTP and TLS servers with test credentials. The same tests run against
mainthrough a Go source overlay, then against this branch.Before:
After:
Checklist
Client.Domake testwith race detection and coverage on Go 1.27.2go vet ./...