MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Validate

Function Validate

pkg/auth/password.go:85–101  ·  view source on GitHub ↗

Validate checks if the hash matches the plaintext.

(hashed, plain string)

Source from the content-addressed store, hash-verified

83
84// Validate checks if the hash matches the plaintext.
85func Validate(hashed, plain string) (bool, error) {
86 parts := strings.SplitN(hashed, "$", 2)
87
88 if len(parts) < 2 {
89 return false, errInvalidHash.New()
90 }
91
92 typ := parts[0]
93
94 for _, method := range hashValidators {
95 if strings.EqualFold(typ, method.Name()) {
96 return method.Validate(hashed, plain)
97 }
98 }
99
100 return false, errUnknownHashingMethod.WithAttributes("method", typ)
101}

Callers 7

ClientSecretMatchesMethod · 0.92
LoadRefreshMethod · 0.92
updateUserPasswordMethod · 0.92
authInfoMethod · 0.92
DoLoginMethod · 0.92
TestHashFunction · 0.85
TestLegacyFunction · 0.85

Calls 4

NewMethod · 0.65
NameMethod · 0.65
ValidateMethod · 0.65
WithAttributesMethod · 0.45

Tested by 2

TestHashFunction · 0.68
TestLegacyFunction · 0.68