views:

83

answers:

3

I have a simple web application set up where admins can create users. Users do not 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?

+2  A: 

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.

Dave Swersky
Yes the admin calling would probably piss the admin off if you had told them they had to do that. I was just curious on if there are any ways I can add an extra level of security so I can be a little more assured that it is the person I e-mailed the temporary password to that is actually changing their password.
Xaisoft
A: 

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

Gregoire
Can you elaborate on this more? Do you mean like the url with a GUID?
Xaisoft
yes and send this URl to the user by mail
Gregoire
I am little confused, doesn't this still require me to send the temporary password in e-mail?
Xaisoft
In fact, paulthenerd has better explained it than me :). No need to send a password, the guid (or hash) will help you to retieve the user and the probality that one can retrieve this url without the mail is nearly null
Gregoire
+3  A: 

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.

paulthenerd
What do you mean by invite record?
Xaisoft
By invite record I mean a database record that would record the invite hash, the user's email address and the timestamps and/or expiry information for the invite
paulthenerd