NGINX Modern Apps > Class 3 - NGINX Dataplane Scripting Source | Edit on
Generating JWT token [http/authorization/gen_hs_jwt]¶
This example will construct a JSON Web Token (JWT) from scratch including generating the digital signature.
Step 1: Use the following commands to start your NGINX container with this lab’s files: Notice the JWT_GEN_KEY environment variable
Step 2: Now let’s use curl to test our NGINX server:
Code Snippets¶
This config uses js_set to invoke the jwt function in our njs code. The generated JWT is returned in the response body.
The njs code creates a claims object and then builds the JWT by combining the header, claims, and a digital signature.