Hi I'm completely new to cherrypy, and very happy with initial tests.
I'm getting into an issue I can not get througt.
With authentication, I want like im my bank pages, that when I open al
new tab in the browser, and type the main url to be asked again for a
password, to be logged in as two(many) different users.
It seems that the presence of a cookie defines that a user has logged
in
How can that be done?
This looks dangerous. All the client has to do is send a cookie with a
'userid' key and some random value. Thats pretty easy with firefox and
the ModifyHeaders extension. All the attacker needs to know is the name
of your session key which happens to be 'userid'.
To make this secure you need to generate a value for 'userid' (commonly
a md5/sha hash), store it somewhere and compare the values for each
request. Please tell me I'm wrong ;)
cheers
Paul
Actually CherryPy's built in session stuff that Arjuna is using doesn't
work that way. The cookie that is created will be something like:
Cookie: session_id=943618a394b5a06dc90c92cb61ddcdb47ddf65b4
cherrypy.session is just a simple way to store information that you want
to associate with that session. Now, it is true that an end user can
hijack a session if they get the session_id value. So you'd want to
make sure that you forced everything over SSL if you really needed it to
be secure.
Jason
cheers
Paul
Did you actually *try* that. It certainly doesn't work for me.
cherrypy.session['userid'] = 'jason'
Doesn't create a cookie named 'userid' with the value set to 'jason'.
It takes a session object that corresponds to the cookie
session_id=<some hash> and puts information in it that can be retrieved
later. This information is not saved in the cookie on the client
machine, but instead is save on the server (in memory by default, but it
can be saved elsewhere).
In other words, it does what you probably want it to do.
Logging in isn't as easy as setting a userid cookie. Instead you would
have to guess the session_id hash of someone that is logged in.
Jason
>> Ok, but I don't want to hijack a session, I want access to the protected
>> pages and I can do that by just sticking a 'userid' key in my Cookie:
>> header line. I wouldn't call that protection.
>>
>>
>> cheers
>> Paul
>
> Did you actually *try* that. It certainly doesn't work for me.
Now I did. Of course you are right, the "session object" is server-side
and the session_id Cookie is just to link the "browser session" to the
correct "session object". Thanks for poking me.
cheers
Paul
Thanks for explaining the whole thing with the correct terminology.
Part of the reason that I try to help (when I can) is that I invariably
learn something.
Jason
Not with a new tab, but you can do it with a new window. Session
cookies are sent without an expiration time, which makes them live in
the memory of the browser instance, so that they expire when the browser
exits. Most of today's browsers run a new instance for each new window,
and each instance has its own local cookie set. Multiple tabs run in
the same instance, so they share a single cookie set.
If you send a cookie with an expiration time in the future, that gets
stored in a cache, and thus should be inherited by other instances.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.