User-Self-Registration, Sending verification code using Twilio

This topic has 7 replies, 4 voices, and was last updated 4 weeks, 1 day ago by Andy Cory.

  • Author
    Posts
  • #27846
     sireeshanp
    Participant

    hello

    We have an usecase with OpenAM user self registration with sending verification email to user, and registration completes after user clicks on the verification email. Now this is a OOB usecase but only problem is we cannot use the Email server configuration to send emails. The reason being our email is cloud service and they cannot open SMTP port to receive requests from OpenAM servers. So we want to use a service like Twilio to send user verification email? How to acheive this?

    thanks
    sireesha

    #27847
     Jatinder Singh
    Participant

    I suggest looking into Twilio Verify Auth Nodes on Marketplace. It taps into Twilio’s verify service and you could configure Email channel with instructions available in the README doc of the auth node.

    Hope it helps!

    https://backstage.forgerock.com/marketplace/api/catalog/entries/AXETwHU7nnbgOG9zpJP1

    #27852
     sireeshanp
    Participant

    Thanks Jaitnder, I alredy looked into this. This will help us to implement 2-factor authn using Twilio or some other service to send OTP. But the usecase here is for User-Self registration as shown in this guide

    https://backstage.forgerock.com/docs/am/6.5/user-self-service-guide/index.html#

    For user to receive that confirmation email and click verify, we need to configure email server in Global/Realm settings. Which is where my challenge is.

    One of the flows here show a custom plug-in, but I dont see much information on how to invoke a custom plug-in in user registration flow. Could you point me with some sample code and also document on how to invoke this custom plugin.

    #27853
     Jatinder Singh
    Participant

    You can override org.forgerock.openam.selfservice.config.flows.UserRegistrationConfigProvider class under Advanced Configuration to provide custom user registration option. That said, I believe Twilio uses SendGrid for email verification. SendGrid provides multiple ways to tap into their service e.g. API, SMTP and Marketing Campaigns. You may want to look into their SMTP documentation at the below link:

    https://sendgrid.com/resource/setting-up-your-email-infrastructure-with-twilio-sendgrid/
    https://sendgrid.com/blog/smtp-service-crash-course/
    https://sendgrid.com/docs/for-developers/sending-email/getting-started-smtp/

    #27855
     Andy Cory
    Participant

    Hi

    An alternative option to that proposed by Jatinder is to override the use of the default mail-sending class in the Email Service provider. By default this is org.forgerock.openam.services.email.MailServerImpl. The methods in this class have access to the registration mail content; mail body, subject, the link back into AM including the tracking JWT etc. Instead of sending via SMTP, your own implementation could hook into another mechanism. We’ve done this to construct an XML document containing the email info and send it via an OAuth2 REST endpoint to IBM’s Transact marketing platform, for example.

    -Andy

    #27856
     sireeshanp
    Participant

    Thanks Andy, this is very helpful. I will look into the SDK documentation. Is there a sample code which we can use?

    #27875
     Scott Heger
    Participant

    All the samples ForgeRock provides can be found at https://stash.forgerock.org/projects/OPENAM/repos/am-external/browse. There doesn’t appear to be a sample for a custom MailServerImpl though. Through your support contract you can request access to the full AM source code where you could see the OOTB MailServerImpl and model your own after that. If that doesn’t work you could look for an older version that can be found online (e.g. https://github.com/OpenRock/OpenAM/blob/master/openam-core/src/main/java/org/forgerock/openam/services/email/MailServerImpl.java)

    #27878
     Andy Cory
    Participant

    Not that I know of. But the default mail server implementation class, org.forgerock.openam.services. MailServerImpl is available in various online repos so you can see what objects are available to the methods and how the mail is constructed to send to the SMTP server. It should be simple enough to use that code as a basis to use a different method than SMTP to send the message.

    -Andy

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

©2020 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?