wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
745 stars 723 forks source link

Fix docs related to SMS based recovery flows #8554

Open mefarazath opened 4 years ago

mefarazath commented 4 years ago

Is your suggestion related to an experience ? Please describe. Seems like Nexmo and other providers have API changes and we need to include instructions on how we can fix the publisher to adhere to the required format.

somindatommy commented 4 years ago

Seems like NEXMO has request body to application/x-www-form-urlencoded. If we change the publisher as follows it will work.

<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="HTTPOutputEventAdapter" processing="enable"
    statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
    <from streamName="id_gov_sms_notify_stream" version="1.0.0"/>
    <mapping customMapping="enable" type="text">
        <inline><![CDATA[api_key=1234567&api_secret=123456789hfdsert&from=NEXMO&to={{mobile}}&text={{body}}]]></inline>
    </mapping>
    <to eventAdapterType="http">
        <property name="http.client.method">httpPost</property>
        <property name="http.headers">Content-Type:application/x-www-form-urlencoded</property>
        <property name="http.url">https://rest.nexmo.com/sms/json</property>
    </to>
</eventPublisher>

More information can be found at https://developer.nexmo.com/api/sms

somindatommy commented 4 years ago

In order to user TWILO, we can use the following publisher.

<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="HTTPOutputEventAdapter" processing="enable"
    statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
    <from streamName="id_gov_sms_notify_stream" version="1.0.0"/>
    <mapping customMapping="enable" type="text">
        <inline><![CDATA[Body={{body}}&From=+12058589069&To={{mobile}}]]></inline>
    </mapping>
    <to eventAdapterType="http">
        <property name="http.client.method">httpPost</property>
        <property name="http.headers">Content-Type:application/x-www-form-urlencoded,Authorization:Basic <basic_auth_header_value></property>
        <property name="http.url">https://api.twilio.com/2010-04-01/Accounts/AC0af3fhbsdf372749224ebd57b8350cf/Messages.json</property>
    </to>
</eventPublisher>
somindatommy commented 4 years ago

In a publisher, if we want to specify the content-type, we can add it as a header. If we have multiple headers, we can add them in a comma(,) separated manner.

<property name="http.headers">Content-Type:application/x-www-form-urlencoded,Authorization:Basic QUMwYWYzZjg2ZTMwMmQ2Y2QzNDFlOGViZDU3YjgzNTBjZjplMTc3Y2YzMzNjYjY2MTMwODlhZGRjZDU4N2UwYTJlMA==</property>

For content-type application/x-www-form-urlencoded, mapping type to text. If the endpoint expects a json set it as json.

<mapping customMapping="enable" type="text">

We cannot add any query params to property tags. Instead, if we have any query params, we should mention them within mapping tags.

<mapping customMapping="enable" type="text">
    <inline><![CDATA[Body={{body}}&From=+12058589069&To={{mobile}}]]></inline>
</mapping>