File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
gateway/policies/api-key-auth/v1.0.0 Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,20 @@ func (p *APIKeyPolicy) Mode() policy.ProcessingMode {
8888// OnRequest performs API Key Authentication
8989func (p * APIKeyPolicy ) OnRequest (ctx * policy.RequestContext , params map [string ]interface {}) policy.RequestAction {
9090 // Get configuration parameters
91- keyName := params ["key" ].(string )
92- location := params ["in" ].(string )
91+ keyName , ok := params ["key" ].(string )
92+ if ! ok || keyName == "" {
93+ return p .handleAuthFailure (ctx , "missing or invalid 'key' configuration" )
94+ }
95+ location , ok := params ["in" ].(string )
96+ if ! ok || location == "" {
97+ return p .handleAuthFailure (ctx , "missing or invalid 'in' configuration" )
98+ }
9399
94100 var valuePrefix string
95101 if valuePrefixRaw , ok := params ["value-prefix" ]; ok {
96- valuePrefix = valuePrefixRaw .(string )
102+ if vp , ok := valuePrefixRaw .(string ); ok {
103+ valuePrefix = vp
104+ }
97105 }
98106
99107 // Extract API key based on location
You can’t perform that action at this time.
0 commit comments