diff --git a/cli/mobycli/pat_suggest.go b/cli/mobycli/pat_suggest.go index 2ba157e25..65504924f 100644 --- a/cli/mobycli/pat_suggest.go +++ b/cli/mobycli/pat_suggest.go @@ -30,9 +30,10 @@ 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/` +) - // patPrefix represents a docker personal access token prefix. - patPrefix = "dckrp_" +var ( + patPrefixes = []string{"dckrp_", "dckr_pat_"} ) // displayPATSuggestMsg displays a message suggesting users to use PATs instead of passwords to reduce scope. @@ -71,8 +72,10 @@ func isUsingPassword(pass string) bool { if _, err := uuid.ParseUUID(pass); err == nil { return false } - if strings.HasPrefix(pass, patPrefix) { - return false + for _, patPrefix := range patPrefixes { + if strings.HasPrefix(pass, patPrefix) { + return false + } } return true } diff --git a/cli/mobycli/pat_suggest_test.go b/cli/mobycli/pat_suggest_test.go index 61d775512..a10c29440 100644 --- a/cli/mobycli/pat_suggest_test.go +++ b/cli/mobycli/pat_suggest_test.go @@ -89,6 +89,11 @@ func TestIsUsingPassword(t *testing.T) { "dckrp_ee5607c41bcd", false, }, + { + "prefixed personal access token", + "dckr_pat_ee5607c41bcd", + false, + }, } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) {