mz280: fix harbor authentication #369
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #280 chainguard-dev/kaniko#184
Description
docker cli auth (default provider) actually handles two credential sources internally.
DOCKER_AUTH_CONFIGenvironment variable and/kaniko/.docker/config.jsonfile. It always gives priority to the environment variable docker/cli#6171. This causes issues where users had read-only credentials for harbor configured instance wide in the environment variable and push credentials stored in the local configfile. Our usage of docker cli would ignore the push credentials and instead fail hard with the readonly credentials.In a sense this is similar to the issue we had with google credential helper here GoogleContainerTools/kaniko#3328, where we implicitly used invalid credentials to authenticate to gcr, and then failed even though the repository was public. The underlying issue is that if authentication of the highest priority key fails, we just give up, instead we should try out unauthenticated and all keys in order by default, this way credentials can't be shadowed by "higher priority" ones.
As a stop-gap solution to improve the discoverability of these kind of issues we now explicitly log the used credential providers and add an additional warning if
DOCKER_AUTH_CONFIGcan shadow your other configs.