|
-
Dec 29th, 2005, 12:12 PM
#1
Logins, Portals, and Security! oh My!
I am looking to develop a web application that will have the user login and, once logged in, gives the user access to different website components.
Now I know how to do a lot of this. My real problem is, I have never done logging so I am unsure what the best, and most secure way is to go about doing so.
Would I just use sessions, store the username and passwor din the sessions and authenticate on every page? That doens't sound like the best way but I am unsure how to do it any other way.
Also, I don't know what kind of encryption to use for storing the passwords in a MySQL database.
-
Dec 29th, 2005, 12:50 PM
#2
Fanatic Member
Re: Logins, Portals, and Security! oh My!
In login.php you ask for the credintals if they are correct store in $_SESSIONS and use that to valiadate for every other page. You can check the credintals in login.php by using $_POST, then like I said store them in $_SESSION (or you could even use cookies ($_COOKIES)...) to 'remember' that user.
The best thing to store passwords in MySQL is MD5 (although its not an encryption, its a hashing algorithm. But even vBulletin uses it, and even phpBB!.)
-
Dec 29th, 2005, 01:37 PM
#3
Re: Logins, Portals, and Security! oh My!
With regards to the logic, have a look at this. Replace the cookie with a session and you'll see that once authenticated, you do not need to reauthenticate on each request.
-
Dec 29th, 2005, 01:38 PM
#4
Re: Logins, Portals, and Security! oh My!
Actually, storing the user ID in the session is sufficient, once you have validated the credentials. This saves you a bit of time.
In general, log-ins (not logging, that's generating log files) can be divided into two parts: authentication and authorization.
Authentication is making sure that a visitor really is who he claims to be, i.e. verifying a username and password.
Based on authentication, the second step is authorization: deciding what the user is allowed to do. There are various ways to go about it: role-based authorization (each user has a role, deciding what he may do - this board software largely uses this approach), individual authorization (permissions are stored per user - e.g. moderators for specific forums here), and a few others.
For complex authorization tasks, here's a good library:
http://phpgacl.sourceforge.net/
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|