We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5eaa6ff + b8e4ce7 commit 4dbda95Copy full SHA for 4dbda95
models/token.go
@@ -57,9 +57,15 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
57
if token == "" {
58
return nil, ErrAccessTokenEmpty{}
59
}
60
- if len(token) < 8 {
+ // A token is defined as being SHA1 sum these are 40 hexadecimal bytes long
61
+ if len(token) != 40 {
62
return nil, ErrAccessTokenNotExist{token}
63
64
+ for _, x := range []byte(token) {
65
+ if x < '0' || (x > '9' && x < 'a') || x > 'f' {
66
+ return nil, ErrAccessTokenNotExist{token}
67
+ }
68
69
var tokens []AccessToken
70
lastEight := token[len(token)-8:]
71
err := x.Table(&AccessToken{}).Where("token_last_eight = ?", lastEight).Find(&tokens)
0 commit comments