Change Docker client to support OAuth-based flow for login

This mechanism exchanges basic auth credentials for an identity token.
The identity token is used going forward to request scoped-down tokens
to use for registry operations.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
Aaron Lehmann 2016-02-23 16:29:16 -08:00 committed by Derek McGowan
parent e896d1d7c4
commit a6d0c66b4c
1 changed files with 6 additions and 1 deletions

View File

@ -57,12 +57,16 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
return err
}
if response.IdentityToken != "" {
authConfig.Password = ""
authConfig.IdentityToken = response.IdentityToken
}
if err := storeCredentials(cli.configFile, authConfig); err != nil {
return fmt.Errorf("Error saving credentials: %v", err)
}
if response.Status != "" {
fmt.Fprintf(cli.out, "%s\n", response.Status)
fmt.Fprintln(cli.out, response.Status)
}
return nil
}
@ -120,6 +124,7 @@ func (cli *DockerCli) configureAuth(flUser, flPassword, serverAddress string, is
authconfig.Username = flUser
authconfig.Password = flPassword
authconfig.ServerAddress = serverAddress
authconfig.IdentityToken = ""
return authconfig, nil
}