Skip to content

feat!: remove ForceAttemptOAuth2 add SetLegacyMode to auth client - #1038

Closed
TerryHowe wants to merge 4 commits into
oras-project:mainfrom
TerryHowe:feature-remove-force-auth
Closed

TerryHowe wants to merge 4 commits into
oras-project:mainfrom
TerryHowe:feature-remove-force-auth

Conversation

@TerryHowe

Copy link
Copy Markdown
Member

Remove ForceAttemptOAuth2 and add SetLegacyMode to the auth client.

@codecov

codecov Bot commented Nov 11, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.55%. Comparing base (d389197) to head (2b4e299).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1038   +/-   ##
=======================================
  Coverage   82.54%   82.55%           
=======================================
  Files          64       64           
  Lines        4779     4781    +2     
=======================================
+ Hits         3945     3947    +2     
- Misses        510      511    +1     
+ Partials      324      323    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the authentication client API by replacing the public ForceAttemptOAuth2 field with a private legacyMode field and introducing a new SetLegacyMode method. The default authentication behavior changes from using the legacy distribution spec to using OAuth2 with password grant.

Key changes:

  • Replaced public ForceAttemptOAuth2 boolean field with private legacyMode field and SetLegacyMode(bool) method
  • Inverted default behavior: OAuth2 is now the default instead of legacy distribution spec
  • Updated all tests to use the new API pattern

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
registry/remote/auth/client.go Replaced ForceAttemptOAuth2 field with legacyMode field, added SetLegacyMode method, and inverted the authentication logic to make OAuth2 the default
registry/remote/auth/client_test.go Removed ForceAttemptOAuth2: true from OAuth2 tests (now use default), added SetLegacyMode(true) calls to legacy distribution spec tests
registry/remote/auth/example_test.go Removed ForceAttemptOAuth2: true from example to use the new OAuth2 default behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread registry/remote/auth/client.go Resolved
Comment thread registry/remote/auth/client.go Resolved
@TerryHowe
TerryHowe force-pushed the feature-remove-force-auth branch 2 times, most recently from 989f536 to eb3124f Compare November 22, 2025 12:41
@TerryHowe
TerryHowe force-pushed the feature-remove-force-auth branch from eb3124f to 989f67e Compare November 22, 2025 13:20

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are now in v3 development, should we just remove ForceAttemptOAuth2?

@shizhMSFT shizhMSFT changed the title feature: remove ForceAttemptOAuth2 add SetLegacyMode to auth client feat: remove ForceAttemptOAuth2 add SetLegacyMode to auth client Nov 22, 2025
@TerryHowe

Copy link
Copy Markdown
Member Author

Since we are now in v3 development, should we just remove ForceAttemptOAuth2?

This pull request does remove ForceAttemptOAuth2 I don't think that will have a big impact on users.

@TerryHowe
TerryHowe requested a review from sabre1041 as a code owner December 26, 2025 16:05
@TerryHowe TerryHowe changed the title feat: remove ForceAttemptOAuth2 add SetLegacyMode to auth client feat!: remove ForceAttemptOAuth2 add SetLegacyMode to auth client Jan 1, 2026
// - https://distribution.github.io/distribution/spec/auth/jwt/
// - https://distribution.github.io/distribution/spec/auth/oauth/
ForceAttemptOAuth2 bool
legacyMode bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do want legacyMode, why not make it an exported field like LegacyMode so that we don't need getter and setter.

TerryHowe added a commit to TerryHowe/oras-go that referenced this pull request Feb 17, 2026
@TerryHowe

Copy link
Copy Markdown
Member Author

Comments have been used in feat/everything branch. Some future PR will cover this.

@TerryHowe TerryHowe closed this Apr 1, 2026
@TerryHowe
TerryHowe deleted the feature-remove-force-auth branch October 16, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3 Things belongs to version 3.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants