Two Factor Authentication

Bruce Armstrong
CODE AUTHOR
Posts: 58
 6 years 2 months ago -  1 year 7 months ago #247 by Bruce Armstrong
Bruce Armstrong created the code: Two Factor Authentication
Sample code showing how to do two factor authentication using PowerBuilder

This message has an attachment file.
Please log in or register to see it.

Last Edit: 1 year 7 months ago by  Bruce ArmstrongReason: Updating code to work with PowerServer and correct timestamp structure defintion

Please Log in or Create an account to join the conversation.

Ramón San Félix Ramón
Posts: 39
 1 week 6 days ago #614 by Ramón San Félix Ramón
Ramón San Félix Ramón replied the code: Two Factor Authentication

I've tested the code and see that QR code generation doesn't work with the Google API.
I've taken the liberty of adapting Bruce's example and adding my QR code generation libraries, so I can test that it does work. I've simplified the generateprovisioningimage function of the u_google_authenticator object.

Now I don't have to pass it the QR code dimension, and it returns a string with the path to the generated code instead of a blob. I've renamed it of_generateprovisioningimage.

Then I've decorated the example as I do with all of mine. I hope you don't mind, Bruce.

I'm leaving you here a copy of today's project in Powerbuilder 2025 build 3711 (Solution) but I always recommend that you download it from Git Hub in case there is an update:

github.com/rasanfe/TwoFactorAuthDemo

To be aware of what I publish you can follow my blog in Spanish:

rsrsystem.blogspot.com

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

Bruce Armstrong
CODE AUTHOR
Posts: 58
 1 year 2 weeks ago -  1 year 2 weeks ago #544 by Bruce Armstrong
Bruce Armstrong replied the code: Two Factor Authentication
Time-based one time passwords (TOTP) is a standard (en.wikipedia.org/wiki/Time-based_one-time_password). As long as the application in question uses the same settings (same start Unix epoch, same interval, same shared key), it should generate the same result. That's why another application and Google Authenticator can produce equivalent values based on equivalent inputs. In particular, that's why the PowerBuilder code and Google Authenticator should produce the same values.

I can't see anyway in Google Authenticator (at least on iOS) to change the settings so that it might generate different values. And Google Authenticator on iOS is what I used when I demonstrated the use of the routine at several Elevates. I can't explain why it's not working for you.

Actually, I can think of one thing. TOTPs are sensitive to the computer you are generating the value on having it's system time set correctly. If that is off by a few seconds, then the wrong interval will be calculated and you will get different values. Make sure the time on your iOS device is correct.

Last Edit: 1 year 2 weeks ago by  Bruce Armstrong

Please Log in or Create an account to join the conversation.

Panos Platanas
Posts: 2
 1 year 2 weeks ago #543 by Panos Platanas
Panos Platanas replied the code: Two Factor Authentication
Thank you Bruce! On the spot as always.
Only one strange issue: It operates just fine with Google Authenticator on Android but not with Google Authenticator using iOS.
Even more strangely, if I use a different 2FA app on iOS, it works.
Have you got any idea why this may happen?

Thank you

Please Log in or Create an account to join the conversation.