Click here to get back home

secure login form

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
secure login form Harris Kosmidhs 06-05-2008
|--> Re: secure login form C. (http://symc...06-06-2008
  `--> Re: secure login form C. (http://symc...06-07-2008
Posted by Harris Kosmidhs on June 5, 2008, 9:15 am
Please log in for more thread options
Hello,

while I'm developing sites for some time I never coded a login form with
security in mind.

I was wondering what guidelines there are.

For my point of view I'm thinking of using md5 passwords (it's an one
way function right?) in db. Is this a correct approach?

Then, if I'm permitted by the server admin I want to use https. Is it as
simple as puting the login form in the httpdocs of the https server an
when login is successful then I just set a session variable? Will I then
be able to read this from a page under http?

Thanks in advance.

Posted by Erwin Moller on June 5, 2008, 10:10 am
Please log in for more thread options
Harris Kosmidhs schreef:
> Hello,

Hi,

>
> while I'm developing sites for some time I never coded a login form with
> security in mind.
>
> I was wondering what guidelines there are.
>
> For my point of view I'm thinking of using md5 passwords (it's an one
> way function right?) in db. Is this a correct approach?

What is it you want to protect against excactly?
If you want the avoid the man-in-the-middle eavesdropping on you: Then
you need https, as you described.

If you are afraid the username/password you store in your database is
hacked somehow, then it can make sense to store them with an md5 hash,
which is one-way encryption indeed.
So that means you, as admin of the database, cannot tell what the
password is since you only see the md5 hash.
You can check of course if a provided password 'translates' to the
stored md5.

Personally, I stopped storing my passwords with a md5 hash in database.
I figured that if somebody can enter my database at will, my site is
hopelessly cracked beyound repair anyway. ;-)


>
> Then, if I'm permitted by the server admin I want to use https. Is it as
> simple as puting the login form in the httpdocs of the https server an
> when login is successful then I just set a session variable? Will I then
> be able to read this from a page under http?

You have NO shared session between you http and https pages.
So if you need that, you must build that yourself somehow.
(You can propagate the sessionid from http to https via a form, and let
the receiving script use that sessionid for its https session. But be
carefull and always remember that your client can set ANY value for
PHPSESSID easily). Always try to hack your own site with all the
knowledge you have about its internals.

Besides that, you also might consider getting a security audit.

>
> Thanks in advance.

Good luck.

Regards,
Erwin Moller

Posted by Captain Paralytic on June 5, 2008, 11:37 am
Please log in for more thread options
On 5 Jun, 15:10, Erwin Moller
> If you are afraid the username/password you store in your database is
> hacked somehow, then it can make sense to store them with an md5 hash,
> which is one-way encryption indeed.
> So that means you, as admin of the database, cannot tell what the
> password is since you only see the md5 hash.
A salt is required here. There are md5 lookup dictionaries on the web
that will give you the "trivial" password that led to a particular md5
hash.

Trivial includes peoples names and lots of other commonly used
passwords. The salt can be stored with the md5 hash, it still stops
the reverse md5 process from being successful.

Posted by Harris Kosmidhs on June 6, 2008, 2:54 am
Please log in for more thread options
Erwin Moller wrote:
> Harris Kosmidhs schreef:
>> Hello,
>
> Hi,
>
>>
>> while I'm developing sites for some time I never coded a login form
>> with security in mind.
>>
>> I was wondering what guidelines there are.
>>
>> For my point of view I'm thinking of using md5 passwords (it's an one
>> way function right?) in db. Is this a correct approach?
>
> What is it you want to protect against excactly?
> If you want the avoid the man-in-the-middle eavesdropping on you: Then
> you need https, as you described.
>
> If you are afraid the username/password you store in your database is
> hacked somehow, then it can make sense to store them with an md5 hash,
> which is one-way encryption indeed.
> So that means you, as admin of the database, cannot tell what the
> password is since you only see the md5 hash.
> You can check of course if a provided password 'translates' to the
> stored md5.
>
> Personally, I stopped storing my passwords with a md5 hash in database.
> I figured that if somebody can enter my database at will, my site is
> hopelessly cracked beyound repair anyway. ;-)
>

And what's your approach now? Clean passwords as text db fields?

>
>>
>> Then, if I'm permitted by the server admin I want to use https. Is it
>> as simple as puting the login form in the httpdocs of the https server
>> an when login is successful then I just set a session variable? Will I
>> then be able to read this from a page under http?
>
> You have NO shared session between you http and https pages.
> So if you need that, you must build that yourself somehow.
> (You can propagate the sessionid from http to https via a form, and let
> the receiving script use that sessionid for its https session. But be
> carefull and always remember that your client can set ANY value for
> PHPSESSID easily). Always try to hack your own site with all the
> knowledge you have about its internals.
>

What should look like what I have to build? Let's say you press "log
in". It load the (https) login.php which finds out you are a user. Then?
A header('http://example.org/loginnext.php?id=$userid') ??
Is there a way not to pass id with GET but with POST without user
submitting the form himself?

thanks

Posted by Erwin Moller on June 6, 2008, 5:09 am
Please log in for more thread options
Harris Kosmidhs schreef:
> Erwin Moller wrote:
>> Harris Kosmidhs schreef:
>>> Hello,
>>
>> Hi,
>>
>>>
>>> while I'm developing sites for some time I never coded a login form
>>> with security in mind.
>>>
>>> I was wondering what guidelines there are.
>>>
>>> For my point of view I'm thinking of using md5 passwords (it's an one
>>> way function right?) in db. Is this a correct approach?
>>
>> What is it you want to protect against excactly?
>> If you want the avoid the man-in-the-middle eavesdropping on you: Then
>> you need https, as you described.
>>
>> If you are afraid the username/password you store in your database is
>> hacked somehow, then it can make sense to store them with an md5 hash,
>> which is one-way encryption indeed.
>> So that means you, as admin of the database, cannot tell what the
>> password is since you only see the md5 hash.
>> You can check of course if a provided password 'translates' to the
>> stored md5.
>>
>> Personally, I stopped storing my passwords with a md5 hash in database.
>> I figured that if somebody can enter my database at will, my site is
>> hopelessly cracked beyound repair anyway. ;-)
>>
>
> And what's your approach now? Clean passwords as text db fields?

Yes.

>
>>
>>>
>>> Then, if I'm permitted by the server admin I want to use https. Is it
>>> as simple as puting the login form in the httpdocs of the https
>>> server an when login is successful then I just set a session
>>> variable? Will I then be able to read this from a page under http?
>>
>> You have NO shared session between you http and https pages.
>> So if you need that, you must build that yourself somehow.
>> (You can propagate the sessionid from http to https via a form, and
>> let the receiving script use that sessionid for its https session. But
>> be carefull and always remember that your client can set ANY value for
>> PHPSESSID easily). Always try to hack your own site with all the
>> knowledge you have about its internals.
>>
>
> What should look like what I have to build? Let's say you press "log
> in". It load the (https) login.php which finds out you are a user. Then?
> A header('http://example.org/loginnext.php?id=$userid') ??
> Is there a way not to pass id with GET but with POST without user
> submitting the form himself?

Well, I was assuming that both the http-domain AND the https domain were
on the same server.
If that is not the case, things will get more complicated, because
you'll have to build a system that uses a common session-storage for
different machines (using a database instead of serialized
session-array, which is default).

The important thing is (when using a common sessionstorageplace) to pass
around the sessionid.
eg, from http to https:
<form action="https://www.example.com/myhttps.php" method="post">
<input type="hidden" name="httpsessid" value="GJHGA577FKJ98FGKJ3">
<input type="submit">
</form>

From www.example.com/myhttps.php you can now pick up the passed
httpsessid from $_POST["httpsessid"] and use that one to pick up the
session under that name.

There are a lot of ins and outs, depending on your serverconfig, so be
sure you test everything you try.

I would advise you to first read through the relevant pages on php.net
so you have a firm understanding of how sessions work before building this.
Be sure how to name a session (PHPSESSID), how to overrule a name, when
sesisons are autostarted, etc etc.

Good luck.

Regards,
Erwin Moller

>
> thanks

Similar ThreadsPosted
Secure Login November 9, 2006, 1:01 pm
Secure Login PHP December 29, 2007, 2:43 pm
secure login system May 4, 2006, 6:41 am
A secure user login example December 18, 2006, 6:58 pm
Secure login tutorial January 5, 2007, 7:21 am
Newbie: How to create secure login with php? July 29, 2004, 3:24 pm
Re: Login form February 27, 2006, 7:03 pm
login varification from 2 tables in one form August 28, 2004, 5:18 am
Proposal for Lite Encryption for Login Form without SSL September 30, 2007, 11:51 pm
Login lgout and login without closing session gives redirection error June 15, 2005, 5:54 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap