Explorar o código

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>
Aaron Lehmann %!s(int64=9) %!d(string=hai) anos
pai
achega
a6d0c66b4c
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      api/client/login.go

+ 6 - 1
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
 }