spaceapid/util/credentials.go
2024-05-26 20:52:15 +02:00

21 lines
552 B
Go

package util
import (
"git.hamburg.ccc.de/ccchh/spaceapid/config"
)
// CheckCredentials validates whether a given username/password pair matches an
// entry in the authDB whose id is present in the validCredentials list
func CheckCredentials(
authDB config.HTTPBACredentials, validCredentials []config.HTTPBACredentialID, username, password string,
) bool {
for _, id := range validCredentials {
if cred, present := authDB[id]; present {
if cred.Username == username && cred.Password == password {
return true
}
}
}
return false
}