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

initiateUpload() fails with gitlab registries due to urlValues["from"] causing an auth failiure #220

Closed
bajacondor opened this issue Jul 5, 2018 · 7 comments

Comments

@bajacondor
Copy link

Authentication to gitlab docker registry is failing on push for blobs that have the from querystring property added when that value is a registry other than gitlab.

Requests like this from initiateUpload():
https://gitlab-registry.example.com/v2/cicd/bazel-reference-implementations/java/blobs/uploads/?from=library%2Fnginx&mount=sha256%3A162f7aebbf400c6fb16f0520254513b6e505b567ca2fb3995311f92a71f0419f

Respond with this:
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"cicd/bazel-reference-implementations/java","Action":"pull"},{"Type":"repository","Class":"","Name":"cicd/bazel-reference-implementations/java","Action":"push"},{"Type":"repository","Class":"","Name":"library/nginx","Action":"pull"}]}]}

@jonjohnsonjr
Copy link
Collaborator

I think this was fixed a couple hours ago 😅

See #219

@mattmoor
Copy link
Collaborator

mattmoor commented Jul 8, 2018

Going to close this. Please feel free to reopen if it repros at HEAD.

@mattmoor mattmoor closed this as completed Jul 8, 2018
@jonjohnsonjr
Copy link
Collaborator

Reopening because it seems this worked for harbor but not gitlab.

Copying @bajacondor 's comment from the PR.

Unfortunately, when pushing to gitlab private registry, This doesn't completely fix the unauthorized issue. Apparently, the scopes (line 48) also have an effect on the way the registry auths the blob write. I was able to successfully push by replacing line 48 with scopes = append(scopes, ref.Scope(transport.PushScope)) which is kind of a hack. I'm not sure what would be better.

@jonjohnsonjr jonjohnsonjr reopened this Jul 10, 2018
@jonjohnsonjr
Copy link
Collaborator

I am admittedly ruby-ignorant, but casually looking through gitlab it seems that they don't handle multiple scopes during the token exchange. I may be misreading, but see here:
https://github.com/gitlabhq/gitlabhq/blob/889098471e6efc5afa63d70d4089c52326fff43e/app/services/auth/container_registry_authentication_service.rb#L57

I wonder if #221 would help with this somehow.

@bajacondor
Copy link
Author

Thank you for re-opening. Also, thank you @jonjohnsonjr for digging into gitlab code. I see also that they refuse a scope where the path is not within the repository:
https://github.com/gitlabhq/gitlabhq/blob/889098471e6efc5afa63d70d4089c52326fff43e/app/services/auth/container_registry_authentication_service.rb#L78
My company is a customer of gitlab. I will open an issue with them.

@jonjohnsonjr
Copy link
Collaborator

Thanks @bajacondor - I just saw this issue as well: https://gitlab.com/gitlab-org/gitlab-ce/issues/48968

Related kaniko issue: GoogleContainerTools/kaniko#181

@jonjohnsonjr
Copy link
Collaborator

Looks like this got fixed on GitLab's side: https://gitlab.com/gitlab-org/gitlab-ce/issues/48968 🎉

@bajacondor can we close this now?

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

No branches or pull requests

3 participants