Skip to content

Commit accd15c

Browse files
committed
compose-cli: fix PAT detection for PAT suggestion
1 parent 6b231d6 commit accd15c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

cli/mobycli/pat_suggest.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ const (
3030
// patSuggestMsg is a message to suggest the use of PAT (personal access tokens).
3131
patSuggestMsg = `Logging in with your password grants your terminal complete access to your account.
3232
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/`
33+
)
3334

34-
// patPrefix represents a docker personal access token prefix.
35-
patPrefix = "dckrp_"
35+
var (
36+
patPrefixes = []string{"dckrp_", "dckr_pat_"}
3637
)
3738

3839
// displayPATSuggestMsg displays a message suggesting users to use PATs instead of passwords to reduce scope.
@@ -71,8 +72,10 @@ func isUsingPassword(pass string) bool {
7172
if _, err := uuid.ParseUUID(pass); err == nil {
7273
return false
7374
}
74-
if strings.HasPrefix(pass, patPrefix) {
75-
return false
75+
for _, patPrefix := range patPrefixes {
76+
if strings.HasPrefix(pass, patPrefix) {
77+
return false
78+
}
7679
}
7780
return true
7881
}

cli/mobycli/pat_suggest_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ func TestIsUsingPassword(t *testing.T) {
8989
"dckrp_ee5607c41bcd",
9090
false,
9191
},
92+
{
93+
"prefixed personal access token",
94+
"dckr_pat_ee5607c41bcd",
95+
false,
96+
},
9297
}
9398
for _, testCase := range testCases {
9499
t.Run(testCase.name, func(t *testing.T) {

0 commit comments

Comments
 (0)