feat(auth): add ForceBasicAuth to override Bearer challenges - #1182
Open
TerryHowe wants to merge 1 commit into
Open
feat(auth): add ForceBasicAuth to override Bearer challenges#1182TerryHowe wants to merge 1 commit into
TerryHowe wants to merge 1 commit into
Conversation
TerryHowe
requested review from
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
May 23, 2026 15:54
This was referenced May 23, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1182 +/- ##
==========================================
+ Coverage 83.06% 83.13% +0.07%
==========================================
Files 82 82
Lines 5756 5758 +2
==========================================
+ Hits 4781 4787 +6
+ Misses 602 599 -3
+ Partials 373 372 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add a ForceBasicAuth bool field to auth.Client. When true, a Bearer challenge from the registry is rewritten to a Basic challenge before credential handling. This is useful for registries that advertise Bearer auth but also accept HTTP Basic for the same credential pair. Implementation is a three-line scheme rewrite in Client.Do(), applied right after parseChallenge() and before the scheme switch, so the rest of the basic-auth path runs unchanged. The override bypasses bearer flow entirely, so it does not interact with the token-fetching logic. Refs oras-project#1141 (split: PR C of A/B/C). Independent of PRs A and B. Signed-off-by: Terry Howe <terrylhowe@gmail.com>
TerryHowe
force-pushed
the
feat/auth-force-basic
branch
from
June 22, 2026 14:35
a8ba8de to
e0e0275
Compare
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
Part 3 of 3 splitting #1141 into reviewable chunks.
Add a
ForceBasicAuth boolfield toauth.Client. When true, a Bearer challenge from the registry is rewritten to a Basic challenge before credential handling. Useful for registries that advertise Bearer but also accept HTTP Basic for the same credential pair.Implementation
Three lines in
Client.Do(), right afterparseChallenge()and before the existing scheme switch:```go
if c.ForceBasicAuth && scheme == SchemeBearer {
scheme = SchemeBasic
}
```
The rest of the basic-auth path runs unchanged. The override bypasses the bearer flow entirely, so it does not interact with the token-fetching logic.
Independence
Independent of PRs A (#1180) and B (#1181). Based directly on `main`. Can land in any order relative to the other two.
Test plan
Replaces #1141 together with PRs A and B.