passwordspassword-recoveryforgot-password

Implement password recovery best practice


I want to to implement password recovery in my web application.

I'd like to avoid using secret questions.

I could just send the password by e-mail but I think it would be risky.

Maybe I could generate a new temporary random password and send it by e-mail but I think it is as risky as the above point.

Can I send a url by e-mail for example http://example.com/token=xxxx where xxxx is a random token associated with the user. So when the user navigates to that url he/she can reset the password.


Solution

  • First off, do not store a plain-text copy of the user's password, or even an encrypted version. You want to only ever keep a hashed copy of the user's password.

    As for recover solutions, I find that the recovery link to change the user's password is the best solution in my experience. It will probably be a bit more convenient for the user, while being largely the same from a security point of view as sending a new random password to be changed after next login. I'd still recommend having the recovery url expire after a reasonable short period of time, as well as only being usable a single time.