Search code examples
wso2wso2-identity-server

wso2 identity server sms custom variables


i'm using wso2 (is) identity server v:5.11.0 , i've configured the sms otp and it's working fine , but the catch the sms provider/gateway need a param called id and cant be static and needed to be unique and generative for each time the sms sent , each time i change that id manually inside the identity provider => Fedrated Authentication => SMS Otp Configuration => http payload it works fine

{
    "UserName": "user",
    "Password": "pass",
    "body": "$ctx.msg",
    "lang": "en",
    "from": "some service",
    "to": "$ctx.num",
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

spent some time searching wso2 docs for anyway to achieve that without luck or maybe i was searching the wrong place in docs

reading wso2 docs for hint googling & searching stack over flow for similar thing


Solution

  • For this requirement, you can use the placeholder replacing mechanism same as dynamic values get propergated to "$ctx.msg", "$ctx.num".

    In your SMS HTTP payload, use "id": "$ctx.id". Then update the SMS OTP authenticator's logic here to replace the $ctx.id using dynamic value.

    https://github.com/wso2-extensions/identity-outbound-auth-sms-otp/blob/e939145826c519aadae2b32dd6ffee92c7fb6f51/component/authenticator/src/main/java/org/wso2/carbon/identity/authenticator/smsotp/SMSOTPAuthenticator.java#L1465

    Then patch the updated SMS OTP authenticator code's compiled jar to IS and try the flow.