How does ASP.NET Forms Authentication really work?

I've always wondered how exactly ASP.NET forms authentication works. Yes, I know how to configure Forms Authentication, but how does forms authentication work in the background?

With the help of a good article, this is how I understand the process (assuming that the user's browser has cookies enabled)...
  1. User tries to access restricted page.
  2. Server looks for ASPXAuth cookie in the request but does not find it.
  1. Server redirects user to Login page as configured in web.config.
  1. User enters username and password and posts to the server.
  2. Server authenticates username and password against store. If valid...
  3. Server sets the Forms Authentication Ticket.
  1. The ticket contains (among other things) the userName, IsPersistent and the ExpirationDate.
  2. The ticket is encrypted and signed using keys from the <machineKey> configuration element (either from web.config or from machine.config)
  3. The ticket is stored in a cookie called ASPXAuth, or in the user's URL.
  1. Server redirects user back to the referring URL.
  2. User's browser requests original restricted page again. This time with the ASPXAuth cookie in the request.
  3. Server looks for ASPXAuth cookie and finds it.
  4. Server decrypts Forms Authentication Ticket  found in the cookie.
  5. Server checks expiration on ticket. If this is still valid...
  6. Server now knows that the user is authenticated and knows the UserName. From here authorization can take place (i.e. code can call the database and find out if the user has access to specific features on the page)
That seems to make sense. The interesting thing about this process is that Session State is not involved at all.
 
 
上一篇:光刻技术的原理和EUV光刻技术前景


下一篇:【转】使用jquery animate创建平滑滚动效果