JSON Web Tokens (JWTs) are commonly used to authenticate users. A JWT carries user information and a field that stores encrypted user information. When you implement JWT authentication, the encrypted user information is decrypted and compared with the input user information. This verifies the user identity. This topic describes how to configure JWT authentication by using an ingress gateway.
Prerequisites
Procedure
- Log on to the ASM console. In the left-side navigation pane, choose .
- On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
- On the Ingress Gateway page, click the ingress gateway that you want to use.
- In the left-side navigation pane, choose .
- In the JWT Config step of the configuration wizard, turn on the Enable gateway JWT authentication switch, configure the parameters, and then click Next.
Parameter Description Issuer The issuer of the JWT. In this example, the parameter is set to testing@secure.istio.io. JWKS Source The JSON Web Key Set (JWKS) that is used to verify JWTs. In this example, jwks is selected. Key Example value: { "keys":[ {"e":"AQAB","kid":"DHFbpoIUqrY8t2zpA2qXfCmr5VO5ZEr4RzHU_-envvQ","kty":"RSA","n":"xAE7eB6qugXyCAG3yhh7pkDkT65pHymX-P7KfIupjf59vsdo91bSP9C8H07pSAGQO1MV_xFj9VswgsCg4R6otmg5PV2He95lZdHtOcU5DXIg_pbhLdKXbi66GlVeK6ABZOUW3WYtnNHD-91gVuoeJT_DwtGGcp4ignkgXfkiEm4sw-4sfb4qdt5oLbyVpmW6x9cfa7vs2WTfURiCrBoUqgBo_-4WTiULmmHSGZHOjzwa8WtrtOQGsAFjIbno85jp6MnGGGZPYZbDAa_b3y5u-YpW7ypZrvD8BgtKVjgtQgZhLAGezMt0ua3DRrWnKqTZ0BJ_EyxOGuHJrLsn00fnMQ"}]}
AdvancedConfig Click AdvancedConfig. In the JWT Rules Advanced Options dialog box, set JWTToken Position, JWT Passthrough, and Transmit Payload through Header based on your needs. - In the Matching Rule step of the configuration wizard, configure the parameters and click Submit.
Parameter Description Match Mode In this example, Auth If Matched is selected. Valid values: - Auth If Matched: The specified requests require JWT authentication.
- Bypass Auth If Matched: The specified requests do not require JWT authentication.
Add Match Rule Turn on the Path switch and set this parameter to /productpage. This configuration indicates that requests to access the /productpage path require JWT authentication. Requests to access other paths do not require JWT authentication. Note In this case, requests to access other paths are allowed if they do not carry JTWs or are denied if they carry invalid JWTs.Then, a message that indicates JWT authentication is successfully configured appears, and native Istio security resources are displayed. You can click YAML to view the resource configurations. - Verify that JWT authentication takes effect.