Implement password recovery best practice

后端 未结 12 934
天命终不由人
天命终不由人 2020-11-30 18:25

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 thi

12条回答
  •  遥遥无期
    2020-11-30 19:17

    It really comes down to how much security you want to have. One the one end of the extreme is a password reset process that involves contacting and certifying that you are who you claim to be, e.g. via id, because your mailbox could be compromised as well. Actually, as people tend to use the same password everywhere this is very likely. On the other end there is the standard approach that involves just sending out an email with a random new password.

    "Secret" questions and answers are just another form of username and passwords with the fatal flaw that they are usually incredibly easy to guess, so good that you don't want to use them.

    To your point about the token, I don't think it makes a big difference in overall security. Whether you send out a token that allows a user to change the password or whether you send out a random password right away doesn't make a big difference.

    Just make sure the token is only usable once and preferably only in a limited time span, e.g. +24h after requesting it.

    And, as pointed out by previous answers, NEVER EVER store plain passwords. Hash them. Preferably add salt.

提交回复
热议问题