DocsEdge Stack
1.4
Filter Type: JWT
Filter Type: JWT
The JWT filter type performs JWT validation on a Bearer token present in the HTTP header. If the Bearer token JWT doesn't validate, or has insufficient scope, an RFC 6750-complaint error response with a WWW-Authenticate header is returned. The list of acceptable signing keys is loaded from a JWK Set that is loaded over HTTP, as specified in jwksURI. Only RSA and none algorithms are supported.
JWT Global Arguments
insecureTLSdisables TLS verification for the cases whenjwksURIbegins withhttps://. This is discouraged in favor of either using plainhttp://or installing a self-signed certificate.renegotiateTLSallows a remote server to request TLS renegotiation. Accepted values are "never", "onceAsClient", and "freelyAsClient".injectRequestHeadersinjects HTTP header fields in to the request before sending it to the upstream service; where the header value can be set based on the JWT value. The value is specified as a [Gotext/template][] string, with the following data made available to it:.token.Raw→stringthe raw JWT.token.Header→map[string]interface{}the JWT header, as parsed JSON.token.Claims→map[string]interface{}the JWT claims, as parsed JSON.token.Signature→stringthe token signature.httpRequestHeader→http.Headera copy of the header of the incoming HTTP request. Any changes to.httpRequestHeader(such as by using using.httpRequestHeader.Set) have no effect. It is recommended to use.httpRequestHeader.Getinstead of treating it as a map, in order to handle capitalization correctly.
Any headers listed will override (not append to) the original request header with that name.
errorResponseallows templating the error response, overriding the default json error format. Make sure you validate and test your template, not to generate server-side errors on top of client errors.contentTypeis deprecated, and is equivalent to including aname: "Content-Type"item inheaders.realmallows specifying the realm to report in theWWW-Authenticateresponse header.headerssets extra HTTP header fields in the error response. The value is specified as a Gotext/templatestring, with the same data made available to it asbodyTemplate(below). It does not have access to thejsonfunction.bodyTemplatespecifies body of the error; specified as a [Gotext/template][] string, with the following data made available to it:.status_code→integerthe HTTP status code to be returned.httpStatus→integeran alias for.status_code(hidden from{{ . | json "" }}).message→stringthe error message string.error→errorthe raw Goerrorobject that generated.message(hidden from{{ . | json "" }}).error.ValidationError→jwt.ValidationErrorthe JWT validation error, will benilif the error is not purely JWT validation (insufficient scope, malformed or missingAuthorizationheader).request_id→stringthe Envoy request ID, for correlation (hidden from{{ . | json "" }}unless.status_codeis in the 5XX range).requestId→stringan alias for.request_id(hidden from{{ . | json "" }})
In addition to the standard functions available to Go
text/templates, there is ajsonfunction that arg2 as JSON, using the arg1 string as the starting indent level.
Note: If you are using a templating system for your YAML that also makes use of Go templating, then you will need to escape the template strings meant to be interpreted by the Ambassador Edge Stack.
JWT Path-Specific Arguments
scope: A list of OAuth scope values that Ambassador will require to be listed in thescopeclaim. In addition to the normal of thescopeclaim (a JSON string containing a space-separated list of values), the JWT Filter also accepts a JSON array of values.