From b42da7fcc3d3490e86e87d661d6716985bea04fa Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Tue, 23 Feb 2016 16:29:16 -0800 Subject: [PATCH] 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 Upstream-commit: a6d0c66b4c923cddeaea09f5b41ad353ea7a9b5f Component: engine --- components/engine/api/client/login.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/engine/api/client/login.go b/components/engine/api/client/login.go index 6696feb8cf..3fc14743de 100644 --- a/components/engine/api/client/login.go +++ b/components/engine/api/client/login.go @@ -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 }