Open
Description
Description
I think you've got the one-time passwords for 2FA wrong…
The concrete problem is #3507, but I think the general thing is a bit wrong.
E.g. the text when generating an one-time password states "when you've logged in with your one-time password, you can generate a new one here". That's not what such a password is for…
So let's skip the problems part and directly explain how it should be done…
This is how such things are handled (in GitHub e.g.). You have two types of static "passwords":
- recovery codes
- That is what you probably mean with the current "one time passwords", but they are numbers only!
- Usually multiple ones are generated (so you can print them and place some of them in different places)
- When one lost their 2FA device, one can use such a code instead of the 2FA code.
- You can only skip the 2FA step, not the password login!
- After use, they are invalidated and cannot be used again. A mail is sent to the user's mail in order to notice them that such a password was used.
- Usually one can display them later in the UI.
- example:
447837
and143782
and01783
- alternatively, you can provide a "lost device" link on the 2FA validation page and have separate, static passwords with letters, which are more secure, i.e.
wOXJlI
. (that's how GitHub does it)
- access tokens (per device!)
- quite long (longer than what you currently issue!), treat them as "API keys"
- They can be saved on a device for git (
.git-credentials
even allows that) and are automatically used for authentication. - You can always use them like a password, but one should not be able to use them from the web interface. (as they should be "bound" to a device)
- The reason why they exist is to allow login on devices, where 2FA input is not supported. (i.e. git) Otherwise we would not need them and just input 2FA codes.
- Only shown once to prevent the user from reusing it for multiple devices.
- They are the only way to authenticate without entering a 2FA code. (i.e. what Block password-only auth when 2FA is enabled #1394 was about)
- Important: They get some label/name, which can be shown in the user's profile. There they can be removed/revoked, e.g. when you've lost a device. That is the whole thing, which makes them useful.
- example:
Gpma2pzZGtsZmprc2RqZmxramRzw7xvd3FlMHFlcmlxd3Bva
Conclusion
So as you see these are two things, with very different purposes. You cannot mix them (as you did currently) and really have to offer two things for that.
Generally, you can have a look at GitHub, where they've implemented it in a pretty decent way.