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

Disable registry fallback for repository credentials #1304

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Jul 19, 2021

As mentioned in containers/common#659 (comment), we now do not normalize the registry when being in non legacy format. This means we do not match "quay.io/foo" if "quay.io/bar" is provided as credentials, because both would be normalized to "quay.io" before this patch.

We also add a new corner case where auth.json has been external modified to contain an entry like "https://quay.io/v1/", which now also matches if "quay.io/foo" has been provided via the credentials.

@TomSweeneyRedHat
Copy link
Member

LGTM

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I may be missing something, but this doesn’t look right at all.

A login quay.io; pull quay.io/foo should find the registry-level credentials; so dropping the registry name from authKeysForRef does not make sense to me. (And also I can’t see that it makes any difference, because the normalizedAuths lookup will find quay.io anyway!)

The originally-reported problem was that a login quay.io/foo; pull quay.io/bar finds the foo credentials, and shouldn’t. AFAICS the normalizedAuths code will find that both before and after this PR.

And for completeness, login https://quay.io/v1/; pull quay.io/foo (with the login done not using our current/future tools, but something that writes such keys into auth.json directly) should continue to find the URL-keyed credential.

The original proposal talked about how this is governed by the format of the key in the config file, not by format of the query. So that’s another reason why changing authKeysForRef, but not changing the keys = []string{registry} is surprising.

Am I missing something about how this works?

Either way this is a bit tricky, so could you add tests for the three cases above to one of the GetAuth* functions, please?

pkg/docker/config/config.go Outdated Show resolved Hide resolved
@saschagrunert saschagrunert force-pushed the no-fallback branch 2 times, most recently from 2ea37fe to b78c420 Compare July 20, 2021 08:35
@saschagrunert
Copy link
Member Author

@mtrmac I think I misunderstood what was required but now added the unit tests and aligned the current implementation to it. Sorry for that, please take a look again.

@saschagrunert saschagrunert force-pushed the no-fallback branch 2 times, most recently from 9b3c204 to e5ef111 Compare July 20, 2021 08:57
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks, this looks closer.

I’m not sure whether some of the design decisions different from containers/common#659 (comment) are accidents or intentional because that proposal is broken; if that’s the case, please write down the rationale, at least here in the PR.

pkg/docker/config/config_test.go Outdated Show resolved Hide resolved
pkg/docker/config/config_test.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
@saschagrunert saschagrunert force-pushed the no-fallback branch 2 times, most recently from 859e839 to 457c01f Compare July 20, 2021 13:48
@saschagrunert
Copy link
Member Author

@mtrmac PTAL, I think I addressed all of your comments.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good, some possible cleanups.

pkg/docker/config/config_test.go Outdated Show resolved Hide resolved
pkg/docker/config/config.go Show resolved Hide resolved
pkg/docker/config/config.go Outdated Show resolved Hide resolved
As mentioned in
containers/common#659 (comment), we
now do not normalize the registry when being in non legacy format. This
means we do not match "quay.io/foo" if "quay.io/bar" is provided as
credentials, because both would be normalized to "quay.io" before this
patch.

We also add a new corner case where auth.json has been external
modified to contain an entry like "https://quay.io/v1/", which now also
matches if "quay.io/foo" has been provided via the credentials.

Signed-off-by: Sascha Grunert <[email protected]>
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM.

@mtrmac mtrmac merged commit f485252 into containers:main Jul 21, 2021
@saschagrunert saschagrunert deleted the no-fallback branch July 21, 2021 10:56
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.

3 participants