Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 15th, 2003, 04:48 PM
StinkFist StinkFist is offline
Cthulu-ish
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Seattle
Posts: 31 StinkFist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Cookie authentication and encrypting

I'm writing a web app that uses automatic log in with cookies.

that part is fine and dandy and it works a charm. Now I obviously don't want to store an unencrypted userId in the cookie. I'm just not clear on the public/private key thing and how to store the values (and retrieve them when checking the cookie).

The process goes like this:

user logs in
public and private keys are generated
private key is stored
public key is put into cookie with userId

user comes back to the site
cookie value is retrieved
private key is retrieved
public key is checked against private key
if the keys are valid then the user is logged in


I just don't know exactly how to go about doing this.

can the keys be stored in a database and what datatype should they be? should I store them in a string and then write them to the db? (I'm using PostgreSQL)

will they match up if I convert the String back into a byte[] array?

I'm a little lost here so any help would be appreciated, thanks
__________________

Reply With Quote
  #2  
Old March 16th, 2003, 06:58 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
I understand your idea to use a public key for some security, but on the top it does not look like this would be much more secure than having an unencrypted cookie on the users machine.

The idea behind not storing a users name and password in a cookie is that anyone can take the cookie and read the info. However, in the case where it is encrypted using a public key, and the user does not have to supply a user name or anything when accessing the site, then all a malicious someone would have to do is take the cookie and put it on another machine to gain access, no? If I am wrong please correct me, maybe I am missing something.

Reply With Quote
  #3  
Old March 16th, 2003, 09:22 PM
StinkFist StinkFist is offline
Cthulu-ish
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Seattle
Posts: 31 StinkFist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
you're absolutely right, do you have any suggestions?

I've been thinking about storing a second cookie that has the key in it so that both of them would have to be sniffed at the same time. I'd just put a really short expiration on the second one.

Like I said tho, I'm really open to suggestion on this one.

thanks

Reply With Quote
  #4  
Old March 16th, 2003, 09:35 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
I once setup a system so that certain users were 'auto' logged in. What I used was to let users add an IP to their profile. If they were logging in from this IP, then they were not challenged. This will only work if they have a static IP, dialup need not apply.

This also has some security risks. Some I can think of off the top of my head are:
1) If a user sets an IP to a router, all people behind that router can gain access.
2) If someone WERE to use a dialup IP, the next person to get that IP assigned to them from the ISP would be able to gain access (I realize this is highly unlikely to happen, let alone for the person getting the IP to know and utilize this information).

Anyway, auto logins are inherently unsafe. You better decide how private the information is you are trying to guard and decide if the chance of exposure outways the need for convenience.

btw, you can get a users IP using:
Code:
request.getRemoteAddr();

if you were wondering.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Cookie authentication and encrypting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT