Bump faas-provider to 0.12.0

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2019-10-19 09:54:50 +01:00
committed by Alex Ellis
parent d58d37dd1f
commit 040819b41c
19 changed files with 8 additions and 594 deletions

View File

@ -4,7 +4,6 @@
package auth
import (
"crypto/subtle"
"net/http"
)
@ -13,13 +12,10 @@ func DecorateWithBasicAuth(next http.HandlerFunc, credentials *BasicAuthCredenti
return func(w http.ResponseWriter, r *http.Request) {
user, password, ok := r.BasicAuth()
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
const noMatch = 0
if !ok ||
user != credentials.User ||
subtle.ConstantTimeCompare([]byte(credentials.Password), []byte(password)) == noMatch {
if !ok || !(credentials.Password == password && user == credentials.User) {
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("invalid credentials"))
return