This commit is contained in:
@@ -47,6 +47,16 @@ func ValidateCreatorSession(secret []byte, token string, now time.Time) (identit
|
||||
func BootstrapMatches(expected, supplied string) bool {
|
||||
return expected != "" && supplied != "" && subtle.ConstantTimeCompare([]byte(expected), []byte(supplied)) == 1
|
||||
}
|
||||
|
||||
func CreatorCredentialsMatch(expectedUsername, expectedPassword string, supplied identity.CreatorCredentials) bool {
|
||||
if expectedUsername == "" || expectedPassword == "" || supplied.Username == "" || supplied.Password == "" {
|
||||
return false
|
||||
}
|
||||
usernameMatches := subtle.ConstantTimeCompare([]byte(expectedUsername), []byte(supplied.Username))
|
||||
passwordMatches := subtle.ConstantTimeCompare([]byte(expectedPassword), []byte(supplied.Password))
|
||||
return usernameMatches&passwordMatches == 1
|
||||
}
|
||||
|
||||
func signature(secret []byte, payload string) string {
|
||||
mac := hmac.New(sha256.New, secret)
|
||||
mac.Write([]byte(payload))
|
||||
|
||||
Reference in New Issue
Block a user