On login, make the server generate an UUID, associate that UUID with the logged in user, and set it as the cookie you will use to identify the user. Then just compare that cookie with your list of logged in users to find who it is.
It should already be a good start.
On 05/15/2012 08:03 PM, Wes James wrote:
_______________________________________________I'm using cowboy for an application and I'm setting a simple cookie with
an expire to log users out after a certain time. Using a simple cookie
seams like it is not secure, though. As someone could read the code and
set the cookie in their browser and then get access to the site, right?
Are there any examples of securely using cookies in cowboy or some
other erlang app/framework that shows how cookies are used? I guess
some random time based cookie might work better.
Thanks,
Wes
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
--
Loďc Hoguin
Erlang Cowboy
Nine Nines
On May 15, 2012, at 8:03 PM, Wes James wrote:One simple approach is to make an expiring process that generates a random binary per user session. Use its value to encyrpt the cookie, encode it somehow so it's browser/cowboy-friendly (I remember I had some trouble using base64 with cowboy cookie module, which led me to a hexstring eventually), then verify it using the onrequest hook.
> I'm using cowboy for an application and I'm setting a simple cookie with an expire to log users out after a certain time. Using a simple cookie seams like it is not secure, though. As someone could read the code and set the cookie in their browser and then get access to the site, right? Are there any examples of securely using cookies in cowboy or some other erlang app/framework that shows how cookies are used? I guess some random time based cookie might work better.
Whatever you choose to do, pass it through SSL and use secure cookies (https://github.com/essen/cowboy/blob/master/src/cowboy_cookies.erl#L28).
Stateless applications are just too hard to secure. I wished there was
a stateful webframework written in erlang, something like java-
webobjects or scala-lift where you can just write your application and
go to sleep without worrying about security. The first time i saw
erlang-web and its component based approach, i thought they got it. I
checked their wiki page but they did not mention security anywhere so
i had to look somewhere else.
On May 17, 2:43 am, Steve Davis <steven.charles.da...@gmail.com>
wrote:
> This is also quite interesting on the topic.
>
> http://www.cse.msu.edu/~alexliu/publications/Cookie/cookie.pdf