Open Source API Gateway

jwtSign

Version

Signs the request or response body as a JWT, replacing the body with the compact JWS serialization (or storing it in a property instead, when property is set). The body must be a JSON object; iat, exp and nbf claims are added automatically before signing.

See tutorials/jwt/20-JWT-Signing.yaml.

Example Configuration

api:
port: 2000
flow:
- template:
contentType: application/json
src: |
{
"sub": "alice",
"aud": "demo-resource"
}

- jwtSign:
property: token
jwk:
location: jwk.json
api:
   port: 2000
   flow:
     - template:
         contentType: application/json
         src: |
           {
             "sub": "alice",
             "aud": "demo-resource"
           }
     - jwtSign:
         property: token
         jwk:
           location: jwk.json

Syntax

jwtSign:
clockSkewSeconds: <int>
expirySeconds: <int>
jwk: {}
property: <string>
jwtSign:
  clockSkewSeconds: <int>
  expirySeconds: <int>
  jwk: {}
  property: <string>

Attributes

NameRequiredDefaultDescriptionExamples
clockSkewSecondsfalse120To account for clock skew between systems, the token's validity start (the nbf claim) is backdated from "issued at" by this many seconds.-
expirySecondsfalse300Time in seconds after which the signed token expires (used to compute the exp claim).-
propertyfalse-Name of an exchange property to receive the signed JWT instead of replacing the message body.-

Child Structure

ElementCardinalityDescription
jwk0..1The RSA key used to sign the JWT.

Can be used in