|
Thanks, I needed that! I've done a lot of programming, some quite advanced,
and likely for longer than 99% of the HN audience.
But this is my first effort with a Web site, HTML,
CSS, etc. So, I believe I can write good code
and think through design issues well enough, but
I am missing some information about mobile devices
and browsers. My little session state store code is working
great. It was fast, fun, and easy to write,
and it's been working flawlessly as I use it
while developing more code. My main alternative was to use what Microsoft's
ASP.NET offered. First they offered storing
session state in the same application (whatever
that is, maybe just an address space). That
alternative would give problems once my site
is busy enough to need more than one Web server
unless I had some front end box, maybe from
Cisco, implement something like session
affinity. The second alternative was
using SQL Server. I'm trying
to keep down the use of SQL Server, especially
for something as light as a session state
store where relational database, with
ACID, etc. is gross overkill. Thanks for the information on cookies:
I don't want to assume or ask that
a user's Web browser accept cookies. When my site goes live, there will be
no reason for users to have a user ID
or password or log in -- later there
will be. So, when I have some users
log in, there is some question just how
to handle that in a way both secure enough
and also really easy for the users.
If the user lets their Web browser
store the user ID and password
(not in a cookie) and a user wants to
use that facility, so far fine with me --
that browser functionality is an industry
standard and, thus, not to be too
embarrassed about. Maybe I can get
some actual documentation of that
browser feature in pages for
programmers at Web sites of the
Web browsers -- Firefox, IE,
Chrome, etc. For using a GUID as a random key,
I don't see what's wrong. I just
ask for a new GUID whenever I need
one. I use GUIDs for so many things
inside my server code that no user
can see a sequence of GUIDs from
one of my servers. So, all a user could
see would be just a few GUID values and
should have one heck of a time
guessing GUID values for other users.
But, a well regarded generator of
random strings would be easy to use
also. I'm familiar with high quality
random number generation, mostly would
want assembler code for the arithmetic,
don't want to try to write Intel
x86 assembler to be called from Microsoft's
Visual Basic .NET, would not want to
use such a random number generator for
session ID, and am not thrilled about
writing my own random string generator.
That's why for now I used GUIDs for
session IDs. But I could ask ASP.NET
to encrypt the GUIDs. Then a user could
grab the encrypted string
and maybe reuse it
but would have to decrypt to see a GUID
to guess the GUID sequence and
extrapolate to a GUID of another
connected user and then encrypt!
Seems a bit much!
Besides, they'd
also have to guess the IP address
of the other connected user and
fake the IP/TCP/HTTP or whatever
headers that report IP address.
Maybe the NSA, some guys in a
big basement in China, or some
brilliant, bored wacko in
Belarus wouldn't have anything
better to do! For what is stored in session state,
I add to that right along as I
write the rest of my Web pages. So I have a class,
marked as <Serializable()>
and add properties to it
as I want
something persistent
during the user's logical session.I read somewhere that Web browsers
on smart phones don't support cookies.
Good to learn that this is not correct. Since cookies are now a privacy concern,
I'm still reluctant to ask my users
to have cookies enabled for my site.
For persistence a session ID, I don't need
a cookie and can use just a GUID
(or a random string)
in a hidden field. For persistence
for user ID and password, my site
doesn't use those yet! Thanks for the answers! |
As for using either in process or SQL Server way of storing the session tokens - there is also a third way and that is writing your own session storage provider, it should be relatively easy and have all the advantages of rolling your own solution and ASP.NET session ID strength http://msdn.microsoft.com/en-us/library/ms178587(v=vs.100).a...
I don't believe you need to do anything special for the password storing (in browser) to work - just keep the same name or id on the HTML elements which accept the username and password and the URL of the login page.
An attacker can just fire as many requests as your simplest page can handle with incrementing GUIDs (not necessarily incrementing by one, GUIDs are made of some machine identification and current time so there is probably even smarter way). If any of the requests doesn't result in "Session expired" page, the attacker has just defeat your session ID because of using GUID. If you go with the custom session storage you can avoid this problem.
When you store stuff in the HttpSessionState, it gets stored (by default) in the memory of the process, it will use the custom session storage provider, if you write one.
I believe that 100% of users accept cookies. But it's true that for storing session id you don't really need it. Also in the EU we now have this stupid law requiring websites to inform users that they use cookies... http://econsultancy.com/nl/blog/9202-eu-cookie-law-three-app...
Good luck with the website - you sound like you're just the right amount of crazy for changing the world :)