Read secrets from variable path

This change enables secrets to be read from any mount on disk
rather than hard-coding a certain location which suits Swarm or
K8s. The default value if not specified will look in the Swarm
location of /run/secrets/

README.md (docs) updated and set to off by default.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2018-05-22 14:46:29 +01:00
committed by Alex Ellis
parent a38931ce69
commit 8133414183
9 changed files with 91 additions and 25 deletions

View File

@ -2,10 +2,12 @@ package handlers
import (
"net/http"
"github.com/openfaas/faas/gateway/types"
)
// DecorateWithBasicAuth enforces basic auth as a middleware with given credentials
func DecorateWithBasicAuth(next http.HandlerFunc, credentials *BasicAuthCredentials) http.HandlerFunc {
func DecorateWithBasicAuth(next http.HandlerFunc, credentials *types.BasicAuthCredentials) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
user, password, ok := r.BasicAuth()
@ -21,9 +23,3 @@ func DecorateWithBasicAuth(next http.HandlerFunc, credentials *BasicAuthCredenti
next.ServeHTTP(w, r)
}
}
// BasicAuthCredentials for credentials
type BasicAuthCredentials struct {
User string
Password string
}