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

Method Valid

controlplane/admin/dashboard.go:57–67  ·  view source on GitHub ↗

Valid reports whether got matches any accepted token. Every candidate digest is compared with subtle.ConstantTimeCompare and there is no early exit on a match.

(got string)

Source from the content-addressed store, hash-verified

55// digest is compared with subtle.ConstantTimeCompare and there is no early
56// exit on a match.
57func (ts TokenSet) Valid(got string) bool {
58 if got == "" {
59 return false
60 }
61 gotSum := sha256.Sum256([]byte(got))
62 match := 0
63 for i := range ts.digests {
64 match |= subtle.ConstantTimeCompare(gotSum[:], ts.digests[i][:])
65 }
66 return match == 1
67}
68
69// Count returns the number of accepted tokens (for operability logging only —
70// never log the values themselves).

Callers 5

TestTokenSetFunction · 0.95
APIAuthMiddlewareFunction · 0.80
loginHandlerFunction · 0.80
AuthMiddlewareFunction · 0.80
appendBuiltinFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestTokenSetFunction · 0.76