Skip to content

Commit 4dbda95

Browse files
authored
Merge branch 'main' into api_repoCreateTag
2 parents 5eaa6ff + b8e4ce7 commit 4dbda95

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/token.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
5757
if token == "" {
5858
return nil, ErrAccessTokenEmpty{}
5959
}
60-
if len(token) < 8 {
60+
// A token is defined as being SHA1 sum these are 40 hexadecimal bytes long
61+
if len(token) != 40 {
6162
return nil, ErrAccessTokenNotExist{token}
6263
}
64+
for _, x := range []byte(token) {
65+
if x < '0' || (x > '9' && x < 'a') || x > 'f' {
66+
return nil, ErrAccessTokenNotExist{token}
67+
}
68+
}
6369
var tokens []AccessToken
6470
lastEight := token[len(token)-8:]
6571
err := x.Table(&AccessToken{}).Where("token_last_eight = ?", lastEight).Find(&tokens)

0 commit comments

Comments
 (0)