update comment (#1057)

This commit is contained in:
田欧
2017-08-16 11:55:50 +08:00
committed by Bo-Yi Wu
parent ecae34c4e1
commit a8fa424ae5
13 changed files with 48 additions and 49 deletions

View File

@ -10,10 +10,10 @@ import (
"strconv"
)
// AuthUserKey is the cookie name for user credential in basic auth
// AuthUserKey is the cookie name for user credential in basic auth.
const AuthUserKey = "user"
// Accounts defines a key/value for user/pass list of authorized logins
// Accounts defines a key/value for user/pass list of authorized logins.
type Accounts map[string]string
type authPair struct {
@ -56,7 +56,7 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
}
// The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using
// c.MustGet(gin.AuthUserKey)
// c.MustGet(gin.AuthUserKey).
c.Set(AuthUserKey, user)
}
}
@ -90,6 +90,6 @@ func secureCompare(given, actual string) bool {
if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 {
return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1
}
// Securely compare actual to itself to keep constant time, but always return false
// Securely compare actual to itself to keep constant time, but always return false.
return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false
}