I have more or less finalized an XData/Sphinx setup (as services on a VPS in the cloud) and all is working nicely (including customized log in screen
) but I am now facing some challenges regarding two factor authentication.
Unfortunately the documentation is quite sparse on this subject so I am looking for some guidance or clues how to fix these issues:
According to the documentation (Login web application | TMS Sphinx documentation), the user should be presented with a QR code after his/her first successful log in. Unfortunately, the QR is not showing. The user is taken straight to input of the 2FA one-time code (verify your ID). What am I missing or doing wrong? This is the code I execute when creating a user:
var
CoreOptions: ICoreOptions;
UsrMgr: IUserManager;
Usr: TSphinxUserEx; // Extended user class
AuthenticatorKey: string;
begin
CoreOptions := TConfigCoreOptions.Create(SphinxConfig);
UsrMgr := TUserManager.Create(CoreOptions, FObjMgr, false);
........
UsrMgr.CreateUser(Usr, dlgUser.Password);
UsrMgr.SetTwoFactorEnabled(Usr, dlgUser.TwoFactorEnabled);
UsrMgr.SetTwoFactorRequired(Usr, dlgUser.TwoFactorRequired);
if Usr.TwoFactorEnabled then
if UsrMgr.GetAuthenticatorKey(Usr) = '' then
UsrMgr.ResetAuthenticatorKey(Usr);
AuthenticatorKey := UsrMgr.GetAuthenticatorKey(Usr);
FMyMailer.SendNewAccountDetails(Usr.Email.Value, Usr.UserName.Value, dlgUser.Password);
FMyMailer.SendAuthenticatorKey(Usr.Email.Value, AuthenticatorKey);
On the off-chance that it was influenced by the customized login screens, I removed the css & img sub-folders and set SphinxConfig.UIOptions.LoginAppFolder := '';. Unfortunately this too makes no difference.
I am also struggling with SphinxConfig.LoginOptions.RequireTwoFactor. I have two users in my test database, one with TwoFactorEnabled AND TwoFactorRequired false and one with both properties set to true. For the latter I have the above problem but setting SphinxConfig.LoginOptions.RequireTwoFactor to true, I would expect 2FA is enforced for ALL users even if individually set to false. I.e. I see no effect on the login process (workflow) for either user. Am I misunderstanding this property and if so, is it documented somewhere how it interacts the two user properties?