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

Bug: auth.AppendScopes does not distinguish between registries #581

Closed
Wwwsylvia opened this issue Aug 31, 2023 · 0 comments · Fixed by #604
Closed

Bug: auth.AppendScopes does not distinguish between registries #581

Wwwsylvia opened this issue Aug 31, 2023 · 0 comments · Fixed by #604
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@Wwwsylvia
Copy link
Member

When copying an artifact from a remote repository to another, we may code something like below:

// add scope hints
scope := auth.ScopeRepository(dst.Reference.Repository, auth.ActionPull, auth.ActionPush)
ctx = auth.AppendScopes(ctx, scope)
// copy
desc, err := oras.Copy(ctx, src, srcRef, dst, dstRef, opts)

This code snippet adds both pull and push scope hints to ctx for the dst repository in order to decrease the number of auth requests on dst in the later copy operation.
However, auth.AppendScopes does not distinguish scopes between registries, resulting in pull and push scopes being requested for both src and dst repository, which is not safe.

@Wwwsylvia Wwwsylvia added the bug Something isn't working label Aug 31, 2023
@Wwwsylvia Wwwsylvia added this to the v2.4.0 milestone Aug 31, 2023
Wwwsylvia added a commit that referenced this issue Sep 27, 2023
The purpose of this PR is to fix the bug, but new APIs are needed to
avoid breaking changes.
1. Introduce `auth.WithScopesForHost`
2. Introduce `auth.AppendScopesForHost`
3. Introduce `auth.GetScopesForHost` and `auth.GetAllScopesForHost`
4. Introduce `auth.AppendRepositoryScope`

Resolves: #581
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia added the enhancement New feature or request label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

1 participant