3 ms·
From earlier, the google_authenticator pam code/project didn't fill me with confidence, but on the project page it does state it supports "emergency scratch cod
by e12e 11y ago
From earlier, the google_authenticator pam code/project didn't fill me with confidence, but on the project page it does state it supports "emergency scratch codes" as well as HOTP -- from looking at the code again, I think they are considered the same thing, and it appears if you enter a scratch code, that'll let you log in (and if the code you enter is an invalid scratch code, the system will check to see if it was a valid time-based code):
https://github.com/google/google-authenticator/blob/3fb90bdae68f21477b5f97978641497d1048ce37/libpam/src/pam_google_authenticator.c#L1583 https://github.com/google/google-authenticator/blob/3fb90bda...
This older article shows a bit of the hoops one could jump through to get a complete system (including the scratch codes etc):
https://www.serverstack.com/blog/2013/02/21/implementing-totp-authentication-into-your-infrastructure/ https://www.serverstack.com/blog/2013/02/21/implementing-tot...
I've successfully played with the python oath code to get 2fa working with "Star Wars: the Old Republic" (the game has a pretty broken interface for setting up 2fa - to the point that a lot of people give up, even if they give subscribers a 20% monthly bonus in in-game currency for using 2fa...).
https://github.com/bdauvergne/python-oath https://github.com/bdauvergne/python-oath
Highly recommended for debugging/playing with OATH, in addition to the "main" oath tools, which IMNHO are much better documented (and comes with the binaries needed to do everything, like manually generating codes etc):
http://www.nongnu.org/oath-toolkit/pam_oath.html http://www.nongnu.org/oath-toolkit/pam_oath.html
For Debian: https://packages.debian.org/jessie/libpam-oath https://packages.debian.org/jessie/libpam-oath
See also the always excellent Arch Linux wiki, which adds a tip about generating qr-codes from the secret (so you can store the secret in eg: Google Authenticator easily):
https://wiki.archlinux.org/index.php/Pam_oath https://wiki.archlinux.org/index.php/Pam_oath
- knorker 11y ago> it does state it supports "emergency scratch codes" as well as HOTP -- from looking at the code again, I think they are considered the same thing, and it appears if you enter a scratch code No. HOTP and TOTP are treated separately. Both of which are separate from scratch codes. HOTP can't "show the future" (well, you can generate multiple codes but it won't be useful for this) and have an order. Scratch codes are exactly N of them, and they're stored in ~/.google_authenticator and don't have an order. They're also twice as long because unlike the normal codes there's 8 (IIRC) valid ones, and they're ALL valid all the time. (until used)
- e12e 11y agoAh, indeed. There's a seperate function for HOTP: https://github.com/google/google-authenticator/blob/3fb90bdae68f21477b5f97978641497d1048ce37/libpam/src/pam_google_authenticator.c#L1334 https://github.com/google/google-authenticator/blob/3fb90bda... And of course the switch statement that handles the core logic starts by checking scratch codes, and if that doesn't work, proceeds to check TOTP/HOTP: https://github.com/google/google-authenticator/blob/3fb90bdae68f21477b5f97978641497d1048ce37/libpam/src/pam_google_authenticator.c#L1582 https://github.com/google/google-authenticator/blob/3fb90bda... I'm not a big fan of this style: https://github.com/google/google-authenticator/blob/3fb90bdae68f21477b5f97978641497d1048ce37/libpam/src/pam_google_authenticator.c#L901 https://github.com/google/google-authenticator/blob/3fb90bda... But at least there's a comment documenting the magic return code (#DEFINE VALID_SCRATCH_CODE = 0, or an enum, or basically anything else, anyone?): /* Checks for possible use of scratch codes. Returns -1 on error, 0 on success, * and 1, if no scratch code had been entered, and subsequent tests should be * applied. */