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

Accept and ignore 'null' as value for X-Registry-Auth #9028

Merged
merged 1 commit into from
Jan 23, 2021
Merged

Accept and ignore 'null' as value for X-Registry-Auth #9028

merged 1 commit into from
Jan 23, 2021

Conversation

mlegenovic
Copy link
Contributor

docker-client is a library written in Java and used in Eclipse to
speak with Docker API. When endpoint /images/search is called,
HTTP header attribute X-Registry-Auth has value "null". This is for
sure wrong but Docker tolerates this value, and call works. With this
patch call works also with Podman. #7857

Signed-off-by: Milivoje Legenovic [email protected]

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Any tests that can be added.
@vrothberg WDYT? I'm a bit leery about making this change, but I'm not seeing another way after going through the issue and this PR.

@mlegenovic
Copy link
Contributor Author

@TomSweeneyRedHat I am also not happy about the proposed change, that is why I took a look at docker/moby code to see how they do it (https://github.com/moby/moby/blob/master/api/server/router/distribution/distribution_routes.go#L37)
Comment there is:

for a search it is not an error if no auth was given, to increase compatibility with the existing api it is defaulting to be empty

It looks like they are parsing this value in various places in the code, and therefore they can make the behavior different from case to case. In Podman this code is centralized (of course much better, less copy/paste code), but it is more difficult to handle such exceptional cases.

I can of course create an issue in other project (docker-client), and let them solve the problem ("null" as value is definitely wrong), if you find this change quite ugly.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

The change looks good to me. There are other places in the code where we've made Java clients happy to remain compatible with Docker.

@jwhonce PTAL

@@ -297,7 +297,7 @@ func imageAuthToDockerAuth(authConfig types.DockerAuthConfig) dockerAPITypes.Aut
func singleAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error) {
authHeader := r.Header.Get(string(XRegistryAuthHeader))
authConfig := dockerAPITypes.AuthConfig{}
if len(authHeader) > 0 {
if len(authHeader) > 0 && authHeader != "null" {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment to both places that explains why need to ignore "null".

@vrothberg
Copy link
Member

@mlegenovic can you run make vendor and update the commit?

@vrothberg
Copy link
Member

CI is failing but will be fixed with #9031. Once merged, please rebase.

docker-client is a library written in Java and used in Eclipse to
speak with Docker API. When endpoint /images/search is called,
HTTP header attribute X-Registry-Auth has value "null". This is for
sure wrong but Docker tolerates this value, and call works. With this
patch call works also with Podman. #7857

Signed-off-by: Milivoje Legenovic <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2021

Thanks @mlegenovic
/approve
/lgtm
Bug for bug compatible.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2021
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mlegenovic, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2021
@openshift-merge-robot openshift-merge-robot merged commit 6cef7c7 into containers:master Jan 23, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants