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

Registry: prevent double authorization when getting a new token #922

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edigaryev
Copy link
Collaborator

@edigaryev edigaryev commented Oct 22, 2024

Problem: normally, the reason we get the HTTP 401 when working with OCI registries is the initial lack of token, in which case AuthenticationKeeper will have no Authentication set, and the authenticationKeeper.header() will return nil.

However, sometimes the cause for the HTTP 401 is that the scopes mismatch, and since the AuthenticationKeeper now already has Authentication, we'll happily add it to a request for a new token (not just for a regular OCI request):

if let (name, value) = await authenticationKeeper.header() {
request.addValue(value, forHTTPHeaderField: name)
}

This results in a token request with two values in the Authorization and causes HTTP 400 for e.g. GitLab Registry.

Solution: never consider AuthenticationKeeper when making a request for a new token.

Resolves #914.

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.

Tart Push to GitLab Registry Failing
1 participant