@@ -28,29 +28,27 @@ defmodule Mix.Tasks.Phx.Gen.Auth do
2828
2929 ## Security considerations
3030
31- By default, `mix phx.gen.auth` generates an authentication solution that allows registration
32- using email and magic links only. Users must verify their email address after registration
33- by clicking a magic link, which both logs them in and confirms their email.
34- This email confirmation is crucial for preventing session fixation attacks .
31+ `mix phx.gen.auth` generates email based authentication, which assumes the user who
32+ owns the email address has control over the account. Therefore, it is extremely
33+ important to void all access tokens once the user confirms their account for the first
34+ time, and we do so by revoking all tokens upon confirmation .
3535
36- If you allow users to immediately log in after registering, either by registering with a password,
37- or by directly logging them in after only providing an email address, the following attack is possible:
36+ However, if you allow users to create an account with password, you must also
37+ require them to be logged in by the time of confirmation, otherwise you may be
38+ vulnerable to credential pre-stuffing, as the following attack is possible:
3839
3940 1. An attacker registers a new account with the email address of their target, anticipating
4041 that the target creates an account at a later point in time.
41- 2. The attacker sets a password (either when registering, or in the settings) .
42+ 2. The attacker sets a password when registering.
4243 3. The target registers an account and sees that their email address is already in use.
4344 4. The target logs in by magic link, but does not change the existing password.
4445 5. The attacker maintains access using the password they previously set.
4546
46- This is why the default implementation raises whenever a user tries to log in by magic link
47- when there is already a password set. You can safely remove this check if you do not allow
48- unconfirmed users to log in. In that case, registering with email and password is still secure.
49-
50- If you want to allow unconfirmed users to log in, you need to ensure that they need to reset
51- their password when they first sign in by magic link. To do this, you can add a required password
52- field to the confirmation LiveView / template and re-use the password change functionality from
53- the settings page.
47+ This is why the default implementation raises whenever a user tries to log in for the first
48+ time by magic link and there is a password set. If you add registration with email and
49+ password, then you must require the user to be logged in to confirm their account.
50+ If they don't have a password (because it was set by the attacker), then they can set one
51+ via a "Forgot your password?"-like workflow.
5452
5553 ## Password hashing
5654
0 commit comments