MCPcopy Create free account
hub / github.com/PostHog/duckgres / ValidateUserPassword

Function ValidateUserPassword

server/auth/policy.go:55–63  ·  view source on GitHub ↗

ValidateUserPassword validates username/password without leaking user existence via credential-compare timing differences.

(users map[string]string, username, password string)

Source from the content-addressed store, hash-verified

53// ValidateUserPassword validates username/password without leaking user existence
54// via credential-compare timing differences.
55func ValidateUserPassword(users map[string]string, username, password string) bool {
56 expectedPassword, userFound := users[username]
57 if !userFound {
58 expectedPassword = invalidPasswordSentinel
59 }
60
61 passwordMatches := constantTimeStringEqual(password, expectedPassword)
62 return userFound && passwordMatches
63}
64
65func constantTimeStringEqual(a, b string) bool {
66 ab := []byte(a)

Callers 3

handleStartupMethod · 0.92
authenticateChildClientFunction · 0.92
TestValidateUserPasswordFunction · 0.85

Calls 1

constantTimeStringEqualFunction · 0.85

Tested by 1

TestValidateUserPasswordFunction · 0.68