开发者

Securing temporary passwords sent through e-mail to users?

开发者 https://www.devze.com 2022-12-09 05:37 出处:网络
I have a simple web application set up where admins can create users. Users do n开发者_JAVA百科ot create themselves.All an admin has to do is enter a username and an e-mail and a temporary password is

I have a simple web application set up where admins can create users. Users do n开发者_JAVA百科ot create themselves. All an admin has to do is enter a username and an e-mail and a temporary password is sent to the user for them to login. This e-mail is sent in plain text format. If the user is logging on for the first time, they are required to change their password and enter a security question and answer. The user obviously has to know their temporary password in order to login for the first time and this is the only way I know of letting them know (through e-mail). The other option would be to have the admin call the user and tell them over the phone or in person their temporary password, but this is not practical. How could I handle a situation like this?


I typically use a temporary url based on an invite record on the back end. Essentially you create an invite record and generate a hash based on some information perhaps the users email address, a timestamp and a random value. Store the hash as part of the invite record and then send them a url with the hash as the parameter.

When they click the link lookup the invite and validate that it exists and has not been used - then allow them to setup their password and invalidate the invite.

It gets rid of the need to send any sort of password and you can set an expiry on your invite records if you want as well.


The scenario you describe is very common- emailing a temporary password and requiring it to be changed on first login. Unless you have a specific problem with this model I see no reason not to use it. Having an admin call users can get complicated- I would avoid this at all costs.


You can generate a custom url with a password and user hash as argument where the user has to log itself. The hash will be difficult to retrieve if the attacker does not have the information

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号