2024-01-13 23:26:04 +01:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
2024-01-31 17:11:15 +01:00
|
|
|
"git.hamburg.ccc.de/ccchh/spaceapid/config"
|
2024-01-13 23:26:04 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|