Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a host-based auth cache as a fallback #651

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

ktarplee
Copy link
Contributor

This PR adds a new exported method called NewRobustCache() and changes the DefaultCache to use the robust cache. The robust cache uses scoped based auth but falls back to host based auth to better handle the situations described in #650 but retain the benefits of scoped based auth (where the token for a repo might be different than another repo in the same registry).

Closes #650

@ktarplee
Copy link
Contributor Author

ktarplee commented Nov 28, 2023

This PR obviously still needs

  • Unit tests
  • Integration testing
  • Documentation

@shizhMSFT
Copy link
Contributor

@ktarplee Would you like to update this PR to reflect the latest discussion in #650?

@ktarplee
Copy link
Contributor Author

@ktarplee Would you like to update this PR to reflect the latest discussion in #650?

I made the name change.

Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (faaa1dd) 75.41% compared to head (25e15fc) 75.46%.

Files Patch % Lines
registry/remote/auth/cache.go 82.35% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #651      +/-   ##
==========================================
+ Coverage   75.41%   75.46%   +0.04%     
==========================================
  Files          59       59              
  Lines        5606     5640      +34     
==========================================
+ Hits         4228     4256      +28     
- Misses       1015     1019       +4     
- Partials      363      365       +2     

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

@ktarplee ktarplee force-pushed the 650-auth branch 2 times, most recently from 6d09a8f to 7e865b8 Compare December 28, 2023 22:00
@ktarplee
Copy link
Contributor Author

I also added unit tests for the hostCache and exported NewSingleContextCache() function. @shizhMSFT

@shizhMSFT shizhMSFT changed the title feat: added a host-based auth cache as a fallback feat: add a host-based auth cache as a fallback Dec 29, 2023
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM and thanks for the update.

registry/remote/auth/cache.go Outdated Show resolved Hide resolved
@shizhMSFT
Copy link
Contributor

@ktarplee LoL. The DCO check failed. Could you fix that?

The cache is implemented as a fallback cache with a host-based as the fallback.

Signed-off-by: Kyle M. Tarplee <kmtarplee@ieee.org>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 48f0943 into oras-project:main Dec 30, 2023
9 checks passed
@Wwwsylvia Wwwsylvia mentioned this pull request Jan 26, 2024
4 tasks
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.

Prevent extra authentication round trips in non-compliant registries
2 participants