First implementation of new config format
- Functionally equivalent to old version at present - Temperature and Humidity sensors not handled yet - Moved HTTP handlers around
This commit is contained in:
parent
7bb676887f
commit
b2f62c7bb0
7 changed files with 125 additions and 121 deletions
20
util/credentials.go
Normal file
20
util/credentials.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"gitlab.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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue