The following is the baseline recommended approach for ensuring safe app authentication:
Argon2id with a minimum configuration of 15 MiB of memory, an iteration count of 2, and 1 degree of parallelism.Most web applications permit account recovery through requesting a password reset via email. This is a weak point in the custodial chain even assuming a savvy user adhering to best-practice password conventions. In which case, secure this and offer it as a login option ... a magic login.
Any custodial changes to user-controlled information must be treated as requiring full authentication. Do not assume that a logged-in user is the authorised account holder.
frontend and submits via API to backend.id.sub (subject) and fingerprint, where sub1 != sub2 and fingerprint1 == fingerprint2.sub = user.id) and the other is returned to the frontend to be stored in the user's browser.fingerprint in the stored and submitted tokens are the same, and submit both to the backend.sub and fingerprint rules.access_token and refresh_token to the frontend.Users may not always have access to email, or use a password manager, making it easier (and faster) to login with a password. A fallback to a stored password must be offered. You could also choose to enforce passwords for admin users.
Clearly a user does not need a password to login with this process, and so there is no enforcement in the core stack. However, an application may require evidence of a deliberate decision in the custodial chain. Enforcing a password is part of that chain, and that raises the need to reset a password if it is ever lost.
Password recovery functions much the same as the magic workflow, with the same dual token validation process, except that the user now goes to a page that permits them to save a new password.
The user can also change their password while logged in, but - mindful of the rules for validation - they will need to provide their original password before doing so.
Time-based One-Time Password (TOTP) authentication extends the login process to include a challenge-response component where the user needs to enter a time-based token after their preferred login method.
This requires that the user:
After that, the user will be challenged to enter a 6-digit verification code to conclude each login.
The login workflow is extended as follows:
sha-1 hashing. That means deliberately dumbing down from sha256.access_token and refresh_token, instead generate a special access_token with totp = True as a key in the token.totp = True can only be used to verify a TOTP submission, not for any other purpose. The user is not considered to be authenticated.post that, plus the access_token with totp = True, to complete authentication and receive the standard access_token and refresh_token.As before, enabling or disabling TOTP requires full authentication with a password.
Persisting the authentication state of a user requires a mechanism to respond to an authentication challenge which does not inconvenience the user, while still maintaining security.
The standard method for doing so is via access_token and refresh_token, where:
Obviously, this still means that a long-living, active refresh_token is equivalent to authentication, which returns us to the caveat raised above:
Any custodial changes to user-controlled information must be treated as requiring full authentication. Do not assume that a logged-in user is the authorised account holder.