From 7fd59a26566338744c45d20f909f1d5eb6ce6768 Mon Sep 17 00:00:00 2001 From: "Harter, Nicholas (Contractor)" Date: Wed, 21 Jun 2017 15:27:09 -0700 Subject: [PATCH] fixes jwtValidator viper unmarshmaling --- src/caduceus/caduceus.go | 16 ++++------------ src/caduceus/caduceus_type.go | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/caduceus/caduceus.go b/src/caduceus/caduceus.go index ab99f603..afdbe6d9 100644 --- a/src/caduceus/caduceus.go +++ b/src/caduceus/caduceus.go @@ -2,7 +2,6 @@ package main import ( "crypto/tls" - "errors" "fmt" "github.com/Comcast/webpa-common/concurrent" "github.com/Comcast/webpa-common/secure" @@ -30,21 +29,14 @@ const ( // getValidator returns validator for JWT tokens func getValidator(v *viper.Viper) (validator secure.Validator, err error) { - no_validators := make(secure.Validators, 0, 0) + default_validators := make(secure.Validators, 0, 0) var jwtVals []JWTValidator - var ok bool - - // obtain valid jwtValidator from configuration - if jwtVals, ok = v.Get("jwtValidators").([]JWTValidator); !ok { - validator = no_validators - err = errors.New("Unable to cast \"jwtValidators\" value as type []JWTValidator") - return - } + v.UnmarshalKey("jwtValidators", &jwtVals) + // make sure there is at least one jwtValidator supplied if len(jwtVals) < 1 { - validator = no_validators - err = errors.New("Supplied jwtValidator list size is less than 1") + validator = default_validators return } diff --git a/src/caduceus/caduceus_type.go b/src/caduceus/caduceus_type.go index 0b862627..daff3771 100644 --- a/src/caduceus/caduceus_type.go +++ b/src/caduceus/caduceus_type.go @@ -34,7 +34,7 @@ type CaduceusConfig struct { ProfilerQueueSize int TotalIncomingPayloadSizeBuckets []int PerSourceIncomingPayloadSizeBuckets []int - JWTValidators interface{} + JWTValidators []JWTValidator } type JWTValidator struct {