views:

109

answers:

4

I am trying to write a website that has user accounts. There isn't much sensitive information other than the password and email address. But I don't really understand what I'm doing; I'm kind of hacking it along as I go. Is there anything I should be keeping in mind with respect to security or any other important details?

+3  A: 

You should:

Recommended Reading:

PHP Security Guide

Sarfraz
Short, sweet, to the point. Thank you very much!
DavidR
@DavidR: You are welcome :)
Sarfraz
+1  A: 

You MUST use the MD5 php function for passwords. Simple way of securing it. Also make sure you use strip_tags in php so that someone cant execute commands in your input boxes. Since there isn't any sensetive data i dont think you need to encrypt anything. Just make sure the login system is perfect and the user has no other way of accessing data without logging in..

Shud suffice for a basic login script..

Ram Bhat
"You MUST use the MD5 php function" => while it's advisable to hash a password, md5() is hardly the only way...
Wrikken
+2  A: 

Use JanRain Engage (formerly rpxnow.com) for authentication. Their solution lets people use their existing credentials from Google, Yahoo, Microsoft, Facebook and others to log into your site. Many of these providers will give a valid OpenID and often a valid email address as a part of the authentication process.

If you use JanRain, you then only have to store the email address or the OpenID for a user, and you don't have to store passwords or password hashes. Furthermore, you don't have to implement any password reset functionality, or "forgot my password". Also your user registration functionality can be much smaller because you start it with a valid email address or OpenID provided by its owner.

The communication between your application and JanRain is authenticated and encrypted, so it is all nice & secure.

Jay Godse
True but also remember that OpenID can have also disadvantages. See http://stackoverflow.com/questions/410085/what-reasons-are-there-not-to-use-openid for an interesting conversation at that regard.
nico
Jay Godse
This might actually be what I will end up using. Thank you for showing me this.
DavidR
+1  A: 

Sarfraz Ahmed brought up some good resources for reading. You could also use a PHP class for user authentication, there are plenty. I my self have put up a project called userFlex on sourceForge http://uflex.sourceforge.net

userFlex has a decent documentation and it does more than just login users; it does registration and field validations, password resets, confirmation codes for registrations, handles sessions and more like autologin.

Again im just putting up userFlex as an example, you could also look into http://www.phpclasses.org/browse/file/5269.html or many other good Classes in PHPclasses.org.

Pablo