go-auth0 / auth0

ARCHIVED Go SDK for the Auth0 platform. This project is now being maintained at: https://github.com/auth0/go-auth0

Home Page:https://github.com/auth0/go-auth0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passwordless Connection cannot be changed to use MessagingServiceSid

yinzara opened this issue · comments

The Options for Passwordless Sms determine if Passwordless uses a single Twilio "From" phone number or a "MessagingServiceSid" (which allows you to send from a group of numbers).

When you use the API, you'll see that when you change the UI to select the Radio button to change between the two options, the "from" and "messaging_service_sid" get set to null for whichever one is not selected. If you set a "messaging_service_sid" without setting "from" to null, it will keep the radio button selected on "From" and simply error if the connection is used if no From number is configured (even though a "messaging_service_sid" is properly configured).

Currently the "From" field of "ConnectionOptionsSms" is set to "omitempty" which prevents null from ever being sent.

I will be submitting a PR that removes this option and some updated tests to verify. "MessagingServiceSid" already did not have "omitempty" so no change was required.

Here is an example response from GET /connection for the SMS connection with a messaging_service_sid set:

{
    "id": "con_XXXXXXXXXX",
    "options": {
      "from": null,
      "name": "sms",
      "totp": {
        "length": 6,
        "time_step": 200
      },
      "syntax": "liquid",
      "template": "Your one-time secure access code is: {{ password }}\n",
      "authParams": {
        "scope": "openid profile read:campaign read:drawing read:offer read:reward read:template read:message create:message",
        "connection": "sms"
      },
      "twilio_sid": "XXXXXXXX",
      "twilio_token": "XXXXXXXXX",
      "disable_signup": true,
      "messaging_service_sid": "XXXXXXXXXXX",
      "brute_force_protection": true
    },
    "strategy": "sms",
    "name": "sms",
    "is_domain_connection": false,
    "realms": [
      "sms"
    ],
    "enabled_clients": [
      "XXXXXXXXXX"
    ]
  }

And here is one with the "from" set:

{
    "id": "XXXXXXXX",
    "options": {
      "from": "+15555555555",
      "name": "sms",
      "totp": {
        "length": 6,
        "time_step": 200
      },
      "syntax": "liquid",
      "template": "Your one-time secure access code is: {{ password }}\n",
      "authParams": {
        "scope": "openid profile read:campaign read:drawing read:offer read:reward read:template read:message create:message",
        "connection": "sms"
      },
      "twilio_sid": "XXXXXXXX",
      "twilio_token": "XXXXXXXXXX",
      "disable_signup": true,
      "messaging_service_sid": null,
      "brute_force_protection": true
    },
    "strategy": "sms",
    "name": "sms",
    "is_domain_connection": false,
    "realms": [
      "sms"
    ],
    "enabled_clients": [
      "XXXXXXXXXXX"
    ]
  }