Skip to content

Commit

Permalink
Merge pull request #26 from Comcast/feature/jwtAuth
Browse files Browse the repository at this point in the history
Feature/jwtAuth
  • Loading branch information
njharter authored Jun 21, 2017
2 parents a5181b7 + 7fd59a2 commit 4896518
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
16 changes: 4 additions & 12 deletions src/caduceus/caduceus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"crypto/tls"
"errors"
"fmt"
"github.com/Comcast/webpa-common/concurrent"
"github.com/Comcast/webpa-common/secure"
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/caduceus/caduceus_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type CaduceusConfig struct {
ProfilerQueueSize int
TotalIncomingPayloadSizeBuckets []int
PerSourceIncomingPayloadSizeBuckets []int
JWTValidators interface{}
JWTValidators []JWTValidator
}

type JWTValidator struct {
Expand Down

0 comments on commit 4896518

Please sign in to comment.