Skip to content

Commit

Permalink
Merge pull request #1008 from n4ss/revert-unencrypted-prompt
Browse files Browse the repository at this point in the history
Revert unencryted storage warning prompt
  • Loading branch information
thaJeztah authored Apr 18, 2018
2 parents 771ccaf + 3acf5d2 commit 8618838
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions cli/command/registry/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,15 @@ func NewLoginCommand(dockerCli command.Cli) *cobra.Command {
return cmd
}

// unencryptedPrompt prompts the user to find out whether they want to continue
// with insecure credential storage. If stdin is not a terminal, we assume they
// want it (sadly), because people may have been scripting insecure logins and
// we don't want to break them. Maybe they'll see the warning in their logs and
// fix things.
func unencryptedPrompt(dockerCli command.Streams, filename string) error {
fmt.Fprintln(dockerCli.Err(), fmt.Sprintf(unencryptedWarning, filename))

if dockerCli.In().IsTerminal() {
if command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), "") {
return nil
}
return errors.Errorf("User refused unencrypted credentials storage.")
}

return nil
// displayUnencryptedWarning warns the user when using an insecure credential storage.
// After a deprecation period, user will get prompted if stdin and stderr are a terminal.
// Otherwise, we'll assume they want it (sadly), because people may have been scripting
// insecure logins and we don't want to break them. Maybe they'll see the warning in their
// logs and fix things.
func displayUnencryptedWarning(dockerCli command.Streams, filename string) error {
_, err := fmt.Fprintln(dockerCli.Err(), fmt.Sprintf(unencryptedWarning, filename))

return err
}

type isFileStore interface {
Expand Down Expand Up @@ -146,7 +139,7 @@ func runLogin(dockerCli command.Cli, opts loginOptions) error { //nolint: gocycl

store, isDefault := creds.(isFileStore)
if isDefault {
err = unencryptedPrompt(dockerCli, store.GetFilename())
err = displayUnencryptedWarning(dockerCli, store.GetFilename())
if err != nil {
return err
}
Expand Down

0 comments on commit 8618838

Please sign in to comment.