This repository was archived by the owner on Nov 27, 2023. It is now read-only.
File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ const (
30
30
// patSuggestMsg is a message to suggest the use of PAT (personal access tokens).
31
31
patSuggestMsg = `Logging in with your password grants your terminal complete access to your account.
32
32
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/`
33
+ )
33
34
34
- // patPrefix represents a docker personal access token prefix.
35
- patPrefix = "dckrp_"
35
+ var (
36
+ patPrefixes = [] string { "dckrp_" , "dckr_pat_" }
36
37
)
37
38
38
39
// displayPATSuggestMsg displays a message suggesting users to use PATs instead of passwords to reduce scope.
@@ -71,8 +72,10 @@ func isUsingPassword(pass string) bool {
71
72
if _ , err := uuid .ParseUUID (pass ); err == nil {
72
73
return false
73
74
}
74
- if strings .HasPrefix (pass , patPrefix ) {
75
- return false
75
+ for _ , patPrefix := range patPrefixes {
76
+ if strings .HasPrefix (pass , patPrefix ) {
77
+ return false
78
+ }
76
79
}
77
80
return true
78
81
}
Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ func TestIsUsingPassword(t *testing.T) {
89
89
"dckrp_ee5607c41bcd" ,
90
90
false ,
91
91
},
92
+ {
93
+ "prefixed personal access token" ,
94
+ "dckr_pat_ee5607c41bcd" ,
95
+ false ,
96
+ },
92
97
}
93
98
for _ , testCase := range testCases {
94
99
t .Run (testCase .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments