Docly

How to authentication with MFA ?

Estimated reading: 2 minutes

To use VG MFA, you need VGMFA license

What is the VGMFAAuthMode ?

In Visual-Guard has 2 types of authentification

  • VGMagicLink that send a link when the user click that validate the authentification (Synchro System)
  • VGOTP that send to the user an OTP after the user need put in the UI

What is the VGMFATransportMode ?

  • SMS that send to a user a SMS contains the MFA mode
  • Email that send an email to the user

Sample

// In this case the VGPrincipal is already load, you want to ask MFA authentification 

var auth = runtime.MFAAuthentication(VGMFATransportMode.SMS, VGMFAAuthMode.OTP);
 //MFA mode selected = OTP sent by SMS
if(auth.IsUserAccountNotYetAvailable)
{
     //If MFA not yet enabled, then Enable it by program
     runtime.MFA.ActiveMFA(runtime.Principal); 
}

//The user don't have any any
if(auth.HasUserAccountMissingEmail)
{
     Console.WriteLine("Email not yet available ");
     //Set an email address
     mailto:runtime.mfa.setemail("xx.xx@novalys.net");
}

//The user don't have any mobile phone
if (auth.HasUserAccountMissingMobilePhone)
{
     Console.WriteLine("Mobile number not yet available");
     //Set an a mobile number
     runtime.MFA.SetMobilePhone("+XXXXXX");
}

// The user need to provide an OTP 
if (auth.IsMFAWaitingUserAction)
{
     Console.WriteLine("Need OTP value:");
     var otp = Console.ReadLine();
     auth = runtime.MFAAuthentication(otp);
}
Share this Doc
CONTENTS