Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
login: Remove the PAT message, it's in docker/cli now (#2261)
Browse files Browse the repository at this point in the history
Signed-off-by: Djordje Lukic <[email protected]>
  • Loading branch information
rumpl authored Aug 2, 2023
1 parent 118cd6d commit d22f3a8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
2 changes: 0 additions & 2 deletions cli/mobycli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func Exec(_ *cobra.Command) {
displayScoutQuickViewSuggestMsgOnBuild(commandArgs)
case "pull":
displayScoutQuickViewSuggestMsgOnPull(commandArgs)
case "login":
displayPATSuggestMsg(commandArgs)
default:
}
}
Expand Down
27 changes: 0 additions & 27 deletions cli/mobycli/pat_suggest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,16 @@
package mobycli

import (
"fmt"
"os"
"strings"

"github.com/docker/cli/cli/config"
"github.com/docker/docker/registry"
"github.com/hashicorp/go-uuid"
)

const (
// patSuggestMsg is a message to suggest the use of PAT (personal access tokens).
patSuggestMsg = `Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/`
)

var (
patPrefixes = []string{"dckrp_", "dckr_pat_"}
)

// displayPATSuggestMsg displays a message suggesting users to use PATs instead of passwords to reduce scope.
func displayPATSuggestMsg(cmdArgs []string) {
if os.Getenv("DOCKER_PAT_SUGGEST") == "false" {
return
}
if !isUsingDefaultRegistry(cmdArgs) {
return
}
authCfg, err := config.LoadDefaultConfigFile(os.Stderr).GetAuthConfig(registry.IndexServer)
if err != nil {
return
}
if !isUsingPassword(authCfg.Password) {
return
}
fmt.Fprintf(os.Stderr, "\n"+patSuggestMsg+"\n")
}

func isUsingDefaultRegistry(cmdArgs []string) bool {
for i := 1; i < len(cmdArgs); i++ {
if strings.HasPrefix(cmdArgs[i], "-") {
Expand Down

0 comments on commit d22f3a8

Please sign in to comment.