Welcome to Dream.In.Code
Become an Expert!

Join 149,495 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,343 people online right now. Registration is fast and FREE... Join Now!




User authentication tips

 
Reply to this topicStart new topic

User authentication tips

snoj
23 Mar, 2007 - 06:56 AM
Post #1

Fell off the face of the earth
Group Icon

Joined: 31 Mar, 2003
Posts: 3,325



Thanked: 9 times
Dream Kudos: 750
My Contributions
Tip #1
Never check if a user profile exists by using their password.

Recently I was charged with researching a helpdesk ticket solution for internal IT. One of the things I knew that had to be part of the system was that users had to be able to use the same username and password that they do for our domain. So wrote a little hack so that they were authenticated against the domain and then an entry was saved to the database to make it as if they registered themselves or we added them manually. For the first draft of this hack users were only added when they first logged in, so checking to see if they existed by password wasn't such a big deal (though there could still be problems with two users having the same password). However later on I wrote another script that added everyone on the domain to the database with dummy passwords to test a "Proxy Ticket" system. No problem, it works for me since my password is already in the database, but today my coworker tried logging in to test it and had an 1062 MySQL error which is the duplicate entry error.

As you may have guessed, since he was supplying his real password and my hack was checking if his account existed by comparing his real password against the dummy one, it was trying to add another account with the same email/username.

User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: User Authentication Tips
23 Mar, 2007 - 10:10 PM
Post #2

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 643



Thanked: 6 times
Dream Kudos: 25
My Contributions
Well, I haven't been around here long enough to know if I should be poking fun at you for making a newbie databasing mistake (seeing as you're a moderator and all), or consoling you with the fact that it's a common mistake to make. So, I'll just smile and nod. biggrin.gif

I will comment though, that it's a good idea to only verify accounts against an unchanging unique field (or combination of fields).


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:07PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month