Skip to content

feature: Mark ForceAttemptOAuth2 deprecated and add SetLegacyMode()#973

Closed
TerryHowe wants to merge 2 commits intooras-project:v2from
TerryHowe:bearer-auth-user-pass
Closed

feature: Mark ForceAttemptOAuth2 deprecated and add SetLegacyMode()#973
TerryHowe wants to merge 2 commits intooras-project:v2from
TerryHowe:bearer-auth-user-pass

Conversation

@TerryHowe
Copy link
Copy Markdown
Member

@TerryHowe TerryHowe commented Jun 7, 2025

Mark ForceAttemptOAuth2 deprecated and add SetLegacyMode() method to ease migration to oras-go v3.

Closes: #972

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.61%. Comparing base (a5c8b77) to head (aaaf837).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #973   +/-   ##
=======================================
  Coverage   80.60%   80.61%           
=======================================
  Files          64       64           
  Lines        6125     6127    +2     
=======================================
+ Hits         4937     4939    +2     
  Misses        864      864           
  Partials      324      324           

☔ 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.

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 45 days with no activity. Remove the stale label or comment to prevent it from being closed in 30 days.

@github-actions github-actions bot added stale Inactive issues or pull requests and removed stale Inactive issues or pull requests labels Jul 28, 2025
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
@TerryHowe TerryHowe force-pushed the bearer-auth-user-pass branch from 38eef35 to aaaf837 Compare September 13, 2025 15:28
@TerryHowe TerryHowe changed the title fix: allow user password for bearer auth feature: Mark ForceAttemptOAuth2 deprecated and add SetLegacyMode() Sep 13, 2025
@TerryHowe
Copy link
Copy Markdown
Member Author

This should work like helm/helm#31212

Copy link
Copy Markdown
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

Is this PR targeting v2?

@TerryHowe TerryHowe changed the base branch from main to v2 October 20, 2025 13:31
@TerryHowe
Copy link
Copy Markdown
Member Author

Is this PR targeting v2?

Yes, thanks. Updated.


// SetLegacyMode favors basic auth even when the registry requests bearer.
func (c *Client) SetLegacyMode() {
c.ForceAttemptOAuth2 = false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wondering what's the scenario of this? This field is defaulted to be false.🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a method for people to use in the future to preserve the old behavior (favor basic auth).

// - https://distribution.github.io/distribution/spec/auth/jwt/
// - https://distribution.github.io/distribution/spec/auth/oauth/
// Deprecated: This will be removed in the future.
// Calling SetLegacyMode() will preserve ForceAttemptOAuth2 set to false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really want to deprecate this when there's no substitute solution?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This deprecation notice is just to let people know if they are using this variable that it is going away.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought this was what was wanted, but I'll create another PR that is a breaking change

@TerryHowe
Copy link
Copy Markdown
Member Author

I created #1038 to replace this pull request.

@TerryHowe TerryHowe closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetchBearerToken reverts too easily to basic authentication

4 participants