user authentication by SQL lookup

P

Paulo Tetovisk

Hello,

I have a doubt, maybe related with "Best Pratices" and "How to do a securely
SQL Lookup to authenticate a user against a Database".

It's a simple solution, everybody nows how to do, but what's more secure ?

Send the query or SP with the following statement:
"SELECT COUNT(*) FROM tb_users WHERE uid = 'foo' AND passwd =
'hashedpassword'" and then check if the answer is 0 or 1 ?

Or

Send a query like "SELECT passwd FROM tb_users WHERE uid = 'foo'" and then
you do the password validation on the webserver that host your application ?

The secound solution has a pro: It "saves" SQL processing, but in the
another hand you send your password hash in throught your password, i don't
think that is the most secure solution. Has the first option any con ?

Thanks in advance!

PT
 
M

Misbah Arefin

This is exactly what we do with out MembershipProviders i.e. return just the
count or the PK matching the username and password.

If the password is stored in plain text then it can be checked either in SQL
or .NET code but I would prefer not returning the password from SQL. You are
already checking for username in your WHERE clause why not also check for
password and return just the id or count (integer - 4 bytes) instead of text
(length of password bytes).

If the password is encrypted (and cant be decrypted) then you need to pass
in the encrypted password to your proc and return a value indicating
successful match or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top