Vithursa Mahendrarajah
1 min readMay 21, 2021

--

You can enable back-end JWT feature to send a JWT to back-end - [1]. This back-end JWT will have the application attributes.

If you have a requirement to send the custom application attributes in headers, then you can do it via a class mediator.

If you enable the back-end JWT feature, the generated JWT will be sent to back-end in X-JWT-Assertion header (by default).

You can follow the steps given below to set the application attributes in the header:

1. JWT header can be extracted in the class mediator.

For example,

((Axis2MessageContext) mc).getAxis2MessageContext().getProperty("TRANSPORT_HEADERS") returns the headers in the request. you can get the X-JWT-Assertion header

2. Decode the JWT

3. Set the relevant attributes as headers

4. Deploy the class mediator

5. Attach the mediation policy to the API

[1] https://apim.docs.wso2.com/en/3.2.0/learn/api-gateway/passing-end-user-attributes-to-the-backend/passing-enduser-attributes-to-the-backend-using-jwt/#passing-enduser-attributes-to-the-backend-using-jwt

--

--

Vithursa Mahendrarajah
Vithursa Mahendrarajah

Written by Vithursa Mahendrarajah

Software Engineer at WSO2, Electronic &Telecommunication Engineering Graduate, University of Moratuwa. Also like to be a content crafter ^_^

Responses (2)