synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruwan Yatawara <>
Subject Re: Introducing transport level (HTTPs etc.) access restriction to APIs
Date Thu, 25 Jul 2013 09:55:35 GMT
On Tue, Jul 2, 2013 at 9:46 AM, Udayanga Wickramasinghe <> wrote:

> converting

Thanks for the response Udayanga! I was indeed able to handle this without
meddling with the axis2 code.

This is how i did it.

1) Introduced a new transports property to api configuration xml (If a
transport is not listed in the api, it will be assumed, the API is
accessible via both HTTP and HTTPs)
2) Introduced a validation in the canProcess method to see if the transport
with which the api is accessed is listed in the transports section of said
3) If its a restricted transport and canProcess returns false, a warning
will be listed on console and a property will be set in the synapse context
to indicate transport was rejected.
4) Message will be directed to main sequence as usual, the user may include
a filter mediator in the main sequence to display a custom error message
using the variables added to synapse/axis2 context. Pls. refer below


<!-- Filter for handling Rest-API access via unauthorized transports  -->
        <filter source="$ctx:TRANSPORT_DENIED" regex="true">
                        <type>Status report</type>
                        <description>Unsupported Transport $2. The
requested resource (/$1) is not available.</description>
                    <arg expression="$axis2:REST_URL_POSTFIX"/>
                    <arg expression="$ctx:IN_TRANSPORT"/>
            <property name="HTTP_SC" value="403" scope="axis2"/>
            <property name="RESPONSE" value="true"/>
            <header name="To" action="remove"/>
            <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
            <property name="ContentType" scope="axis2" action="remove"/>
            <property name="Authorization" scope="transport"
            <property name="Host" scope="transport" action="remove"/>
            <property name="Accept" scope="transport" action="remove"/>


Ruwan Yatawara

View raw message