Two Factor Authentication
Bruce Armstrong
CODE AUTHOR
Posts: 55
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: 11 months 2 days ago by Bruce Armstrong . Reason: Updating code to work with PowerServer and correct timestamp structure defintion
Please Log in or Create an account to join the conversation.
Bruce Armstrong
CODE AUTHOR
Posts: 55
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.
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: 4 months 1 week ago by Bruce Armstrong .
Please Log in or Create an account to join the conversation.
Panos Platanas
Posts: 2
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
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.
Bruce Armstrong
CODE AUTHOR
Posts: 55
Bruce Armstrong replied the code: Two Factor Authentication
I later updated the sample to work with the CoderObject that was introduced in PowerBuilder 2019. Specifically, the base32encode method was added to that object in 2019R2.
You would either need to upgrade to at least PowerBuilder 2019 R2, or manually replace the call to that method with the PowerScript 32 bit encoding method that I posted in the original article.
You would either need to upgrade to at least PowerBuilder 2019 R2, or manually replace the call to that method with the PowerScript 32 bit encoding method that I posted in the original article.
Please Log in or Create an account to join the conversation.