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

Optionally ignore docker's request for storing / deleting credentials #315

Closed
wants to merge 5 commits into from

Conversation

dotboris
Copy link
Contributor

@dotboris dotboris commented Mar 11, 2022

Issue #, if available: #102 & #154

Description of changes:

Currently, both the Add and Delete operations in this helper return a not implemented error. This can lead to issues where docker login and docker logout stop working for the user while displaying a confusing not implemented error.

Following the suggestion in #154 (comment), this PR adds an environment variable (AWS_ECR_IGNORE_CREDS_STORAGE) to optionally ignore these requests and return no error. When AWS_ECR_IGNORE_CREDS_STORAGE=true, instead of returning a not implemented error, we return nil.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dotboris dotboris changed the title Implement both the Add and Delete operations as nops Optionally ignore docker's request for storing / deleting credentials Mar 14, 2022
@kzys
Copy link
Contributor

kzys commented Mar 24, 2022

Let me check with Docker folks first.

GCP is also having the same issue (see https://github.com/GoogleCloudPlatform/docker-credential-gcr/blob/e8a16dd0fa5bb661e304ad850a61ccfaa901045d/credhelper/helper.go#L62-L75). So I'd like to have a vendor-neutral solution.

@jasonheffner
Copy link

I'd rather like to see the feature implemented.. where it simply would raise a warning similar to...

WARNING! Using --password via the CLI is insecure. Use --password-stdin.

but rather

WARNING! Using credentials from AWS ECR credential helper. Docker login ignored.

@danxmoran
Copy link

Commenting to nudge this 😅

Something like this would be a big help for my team. We're trying to migrate our CI from using docker login to using the ECR helper. We hoped that we could do it by adding the helper (and config) to our CI image, then incrementally removing the docker login usage from workflows. As soon as we pushed the change configuring the helper in ~/.docker/config.json all of our workflows started to fail on the docker login steps, and we had to revert.

@hskrtich
Copy link

Would it be possible to add this change now and reconfigure if/when there is a central way to manage this?

@jasonheffner
Copy link

I'm guessing this project is no longer being developed. The last release was over a year ago. This would have been very helpful.

@a544jh
Copy link

a544jh commented Mar 22, 2023

In my opinion an environment variable shouldn't even be needed. The helper is caching the token anyway, so the store command could just validate your AWS credentials and cache the token. Likewise erase could just delete the cache. If caching is disabled these operations cold just be NOPs, and possibly print out a warning.

By throwing errors (as it's doing currently), this helper is essentially not correctly implementing the docker credential helper spec, as can be seen when numerous people are having issues with this helper when docker login isn't working.

@junze-smg
Copy link

Is there any movement to getting this PR reviewed? We ran into this problem today that docker login command failed on not implemented when we specify ecr-login in the config file.

dotboris added 4 commits July 25, 2023 11:04
These two operations are called when docker tries to store and delete
credentials (docker login and docker logout) respectively. This change
makes it so that both of these operations are implemented as nops
instead of returning a "not implemented" error.

The goal here is to ensure compatibilities with applications and tools
that call docker login or docker logout for the user as part of their
normal operations.
@sparr sparr force-pushed the creds-add-delete-nop branch from e2c53bc to 2c6ec84 Compare July 25, 2023 18:04
@sparr sparr requested review from a team as code owners July 25, 2023 18:04
Copy link
Contributor

@ginglis13 ginglis13 left a comment

Choose a reason for hiding this comment

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

godoc nits otherwise LGTM

ecr-login/ecr.go Outdated Show resolved Hide resolved
ecr-login/ecr.go Outdated Show resolved Hide resolved
Comment on lines +83 to +86
WithField("username", creds.Username).
WithField("serverURL", creds.ServerURL).
Warning("Ignoring request to store credentials. " +
"This is not supported in the context of the docker ecr-login helper.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be more useful to output this error message when shouldIgnoreCredsStorage() is not true? and add something like

To ignore this error, set env value `AWS_ECR_IGNORE_CREDS_STORAGE` to true

Copy link
Contributor

@therealvio therealvio Jul 30, 2024

Choose a reason for hiding this comment

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

We're interested in getting this change merged. I have forked and stood up this PR through here: #847 so we can get feedback addressed and hopefully merged soon. Can you please relay feedback for this PR there and I can look at resolving these.

In the meantime:
Can you elaborate on what you mean @swagatbora90? I am not quite sure on what the intention of this suggestion is.

Copy link
Contributor

@therealvio therealvio Jul 30, 2024

Choose a reason for hiding this comment

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

I did some thinking on this, and I think I get what you mean, though unfortunately this would maintain the status quo and not provide the outcome we're looking for here. If this storage of credentials was implemented, then yes, your change would make sense in this case. This is not the case though, we're trying to ignore an error.

To elaborate: My understanding is that we're preserving the notImplemented error if the environment variable isn't being passed, making this ignore capability a choice for the user. The current state of things is that we have no capabilities to just authenticate without storing the credential. Whether or not this is supported doesn't matter. The bottom line is: we want to get the auth done and move on.

The environment variable is meant to provide a means to skip the attempt at storing the credential and throw a non-blocking warning rather than an error. If we inverted the condition for checking shouldIgnoreCredsStorage, users will still get the blocking notImplemented error and doesn't satisfy what the change was intending to achieve. The test TestAddIgnored reflects this behaviour too.

@webratz
Copy link

webratz commented Feb 5, 2024

Is there any hope that this will see some traction and get merged?

@swagatbora90
Copy link
Contributor

@dotboris Are you still working on this? Looks like there is a lot of interest to get this feature in.

@dotboris
Copy link
Contributor Author

dotboris commented Jun 10, 2024

I'm not. I haven't touched this in ages. I don't really have the bandwidth to work on this. If someone wants to take over, feel free to do so.

@jamestelfer
Copy link

@swagatbora90 I can pick this up if you're able to review?

@therealvio
Copy link
Contributor

This PR can be closed in favour of #847 which has picked up the work and finished it off.

@dotboris dotboris closed this Aug 6, 2024
@therealvio
Copy link
Contributor

Update for onlookers: The changes proposed in here, which were completed in #847 have now been merged in. Enjoy.

@dotboris dotboris deleted the creds-add-delete-nop branch August 8, 2024 13:43
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.