From 25f730247db68c42417c96491ece260cd653a843 Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 27 Jul 2017 17:48:28 -0700 Subject: [PATCH] Added basic auth support using the strings in the authHeader configuration property --- src/caduceus/caduceus.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/caduceus/caduceus.go b/src/caduceus/caduceus.go index c8c500f8..205c7bca 100644 --- a/src/caduceus/caduceus.go +++ b/src/caduceus/caduceus.go @@ -3,6 +3,12 @@ package main import ( "crypto/tls" "fmt" + "net/http" + "net/url" + "os" + "os/signal" + "time" + "github.com/Comcast/webpa-common/concurrent" "github.com/Comcast/webpa-common/secure" "github.com/Comcast/webpa-common/secure/handler" @@ -14,11 +20,6 @@ import ( "github.com/justinas/alice" "github.com/spf13/pflag" "github.com/spf13/viper" - "net/http" - "net/url" - "os" - "os/signal" - "time" ) const ( @@ -61,6 +62,15 @@ func getValidator(v *viper.Viper) (validator secure.Validator, err error) { ) } + // TODO: This should really be part of the unmarshalled validators somehow + basicAuth := v.GetStringSlice("authHeader") + for _, authValue := range basicAuth { + validators = append( + validators, + secure.ExactMatchValidator(authValue), + ) + } + validator = validators return