Spomky-Labs / otphp

:closed_lock_with_key: A PHP library for generating one time passwords according to RFC 4226 (HOTP) and the RFC 6238 (TOTP)
MIT License
1.3k stars 148 forks source link

Alphanumeric characters in TOTP passwords #229

Open programarivm opened 2 weeks ago

programarivm commented 2 weeks ago

Description

👋 Hello there,

Is it possible to use alphanumeric chars in TOTP passwords? If so, could you please provide an example in the docs?

🙏 Thanks for the help, and keep up the great work!

Spomky commented 2 weeks ago

Hi,

The OCRA algorithm allow alphanumeric values. But honestly, I'm not sure what the added value is. If you want similar entropy, you can change the period or the number of digits. A string from 0 to 9 will always be easier to read and retype compared to an alphanumeric string. User experience is very important for security measures to be adopted.

programarivm commented 2 weeks ago

Thanks for the prompt response.

At ChesslaBlab we're implementing a passwordless sign-up use case.

We don't want to share any private data with users, so we're thinking along the lines of usernames automatically created by the system such as "preciseKoala" which will then be eventually assigned to users once they've scanned the QR code with their authenticator app. Thus, if using a ten characters long TOTP password containing alphanumeric codes, the probability of hijacking an account will be lower than if using only numbers.

Here's an example of "Sign in" form:

I hope this sample "Sign in" form helps understand what we're trying to do.

Keep it up,

Spomky commented 2 weeks ago

At ChesslaBlab we're implementing a passwordless sign-up use case.

In this case, you should consider Webauthn that is passwordless and in some cases usernameless among all other nice features such as fishing resistance.

programarivm commented 2 weeks ago

It seems as if TOTP using a smartphone is just fine for an online chess app. The thing with WebAuthn is that it is currently requiring a hardware token like YubiKey which has an additional cost. Alternatively, WebAuthn using a smartphone is not too obvious to use if I'm not very much mistaken.

Spomky commented 2 weeks ago

It seems as if TOTP using a smartphone is just fine for an online chess app. The thing with WebAuthn is that it is currently requiring a hardware token like YubiKey which has an additional cost.

No you don't need hardware tokens. Most of the OS now support Webauthn (Android 7+, Windows, iOS/macOS).

Alternatively, WebAuthn using a smartphone is not too obvious to use if I'm not very much mistaken.

From my POV, it's much more simpler compared to OTPs. You can stay on the same screen and not required to type anything. Just try this demo: https://webauthn.spomky-labs.com/ (note that you are not required to set a username or displayname. Just click on the Register or Login buttons).

programarivm commented 2 weeks ago

I'm currently using Authy and FreeOTP to scan the QR codes generated by Spomky-Labs/otphp, however, those two authenticator apps can't scan the WebAuthn QR code at https://webauthn.spomky-labs.com/register

Which app should I use to scan the WebAuthn QR code?

Thank you,

Spomky commented 2 weeks ago

No app is needed. It is natively recognized with your smartphone camera app.

programarivm commented 2 weeks ago

Well, it seems as if my camera is somehow recognizing the QR code since it returns an output like this:

FIDO:/529...660

It just says FIDO with a bunch of numbers. What should I do now with this FIDO code?

See:

programarivm commented 2 weeks ago

Google Authenticator did the trick.

programarivm commented 1 week ago

Maybe TOTP is just fine for some apps. Now preciseKoala can play chess with other users and see their results in the ranking. See https://github.com/Spomky-Labs/otphp/issues/230