mirror of
https://github.com/hacdias/webdav.git
synced 2024-04-21 12:32:06 +00:00
26 lines
489 B
Go
Executable File
26 lines
489 B
Go
Executable File
package lib
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func checkPassword(saved, input string) bool {
|
|
if strings.HasPrefix(saved, "{bcrypt}") {
|
|
savedPassword := strings.TrimPrefix(saved, "{bcrypt}")
|
|
return bcrypt.CompareHashAndPassword([]byte(savedPassword), []byte(input)) == nil
|
|
}
|
|
|
|
return saved == input
|
|
}
|
|
|
|
func isAllowedHost(allowedHosts []string, origin string) bool {
|
|
for _, host := range allowedHosts {
|
|
if host == origin {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|