Chris Spencer
23-Mar-2025, 07:54 PM
I added 2FA to my webapp with the autenticator library and all works well.
I am looking at the later Security Library and it doesnt seem clear how you can apply a known individual secret to the create the QRCode so as it can be reproduced to verify against.
the following code in
Procedure InitializeNewOtpSpec
Handle hoOtp
String sBase32Secret sAccountName
String sOtpSpec
// create new OTP (with new secret)
Get psLoginName of ghoWebSessionManager to sAccountName
Move (sAccountName + "(SecurityDemo)") to sAccountName
Get NewOtp of oMyOtp C_SEC_OTPTYPE_TIME sAccountName to hoOtp
Get SecretAsBase32 of hoOtp to sBase32Secret //<----------------------------------------------------------- This code create the secret with no way to pass and generates a random string in the demo There is no clear way I see to pass aknown string tied to each user
WebSet psCaption of oNewSecretText to (SFormat("This is your new OTP secret: %1"+Character(13)+"Scan this QR code with your OTP app:", sBase32Secret))
// save
Get PackForStorage of hoOtp to sOtpSpec
WebSet psOtpSpec to sOtpSpec
WebSet psValue of oNewSecretQrCode to sOtpSpec
// clean up
Send Destroy of hoOtp
End_Procedure
Am I missing something here.
Tthe Authenticator does what I need but was investigating whether to move to Security Lib
I am looking at the later Security Library and it doesnt seem clear how you can apply a known individual secret to the create the QRCode so as it can be reproduced to verify against.
the following code in
Procedure InitializeNewOtpSpec
Handle hoOtp
String sBase32Secret sAccountName
String sOtpSpec
// create new OTP (with new secret)
Get psLoginName of ghoWebSessionManager to sAccountName
Move (sAccountName + "(SecurityDemo)") to sAccountName
Get NewOtp of oMyOtp C_SEC_OTPTYPE_TIME sAccountName to hoOtp
Get SecretAsBase32 of hoOtp to sBase32Secret //<----------------------------------------------------------- This code create the secret with no way to pass and generates a random string in the demo There is no clear way I see to pass aknown string tied to each user
WebSet psCaption of oNewSecretText to (SFormat("This is your new OTP secret: %1"+Character(13)+"Scan this QR code with your OTP app:", sBase32Secret))
// save
Get PackForStorage of hoOtp to sOtpSpec
WebSet psOtpSpec to sOtpSpec
WebSet psValue of oNewSecretQrCode to sOtpSpec
// clean up
Send Destroy of hoOtp
End_Procedure
Am I missing something here.
Tthe Authenticator does what I need but was investigating whether to move to Security Lib