aaronrenner / phx_gen_auth

An authentication system generator for Phoenix 1.5 applications.
772 stars 55 forks source link

Consider using Argon2 instead of Bcrypt #97

Closed dealloc closed 3 years ago

dealloc commented 3 years ago

Currently passwords are hashed using bcrypt, but we could consider switching to Argon2 (using the argon2_elixir package). OWASP recommends Argon2 in it's modern algorithms, though it notes that when the knowledge to properly tune the parameters is absent bcrypt is a solid alternative (though the argon2_elixir package provides defaults that have been sufficient in my experience). Bcrypt has a few downsides though, most notably that it has a limit on the amount of input data, limiting passwords to 72 characters (and recommended is to lower this to 64 to allow for string termination etc). While you should limit password lengths anyway to prevent DDOS attacks, a lot of password managers generate passwords of up to 125 characters length. Finally, Argon2 was the winner of the password hashing competition, and a lot of resources I read online recommend using it over bcrypt for newer applications.

If there's agreement that Argon2 is a better alternative, I'm willing to make a PR for this.