How to change API Managers authentication failure message to message default content type.


The error response format sent from WSO2 gateway is usually in xml format. Also if need we can change this behavior. To do this we have extension point to customize message error generation. For auth failures throttling failures we have handler to generate messages.

For auth failures following will be used.
/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler.xml

The handler can be updated to dynamically use the content Type to return the correct response.
Once you changed it will work for XML and JSON calls.

Change the file to add a dynamic lookup of the message contentType i.e,
From

<sequence name="auth_failure_handler" xmlns="http://ws.apache.org/ns/synapse">

<property name="error_message_type" value="application/json"/>
<sequence key="cors_request_handler"/>
</sequence>

To
<sequence name="auth_failure_handler" xmlns="http://ws.apache.org/ns/synapse">

<property name="error_message_type" value="get-property('transport', 'Content-Type')"/>
<sequence key="cors_request_handler"/>
</sequence>


No comments:

Post a Comment

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...