I think the data needs to be more than just the username, it needs to be all
of the Assertion data received from CAS. This data needs to be available for
display in the browser, etc. One reason for not wanting to put this data in a
cookie (UserData field I assume) is the potential size of that data.
Also, I want to be sure I understand what you are proposing. Are you saying
to include the information needed to recreate the Principal in the FAT cookie
itself or are you talking about a separate cookie? I think we are talking
about the FAT cookie, but I want to be sure.
In terms of "In subsequent requests, the HttpContext.Current.User and
System.Threading.Thread.CurrentPrincipal are set by the Forms Authentication
module automatically", that's not what I've seen. HttpContext.Currrent.User
is always null at the start of our event handler method. Maybe I am not
understanding what you mean.
-----Original Message-----
From: Scott Holodak [mailto:
[hidden email]]
Sent: Wednesday, May 06, 2009 14:05
To:
[hidden email]
Subject: Re: [cas-dev] .Net JasigCasClient
Bill
My thinking is that you would want to encrypt the information necessary to
recreate the Principal in the cookie. When you authenticate the request, you
attempt to decrypt the cookie. If you can't, it means it was tampered with.
If you can, you recreate the principal with the decrypted data. You don't
literally need to serialize & de-serialize the principal.
If all that you're storing in the cookie is the username, you don't even have
to re-invent the wheel. Just use FormsAuthentication.SetAuthCookie(...). The
benefit here is that the .NET Framework takes care of validating the cookie &
setting up the principal for requests when authenticating subsequent requests.
This is some code from my login handler:
[1] FormsAuthentication.SetAuthCookie(Username, false);
[2] FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(Username,
false, 30);
[3] FormsIdentity Identity = new FormsIdentity(Username);
[4] GenericPrincipal GenericPrincipal = new GenericPrincipal(Identity, null);
[5] HttpContext.Current.User = GenericPrincipal;
[6] System.Threading.Thread.CurrentPrincipal = GenericPrincipal;
In subsequent requests, the HttpContext.Current.User and
System.Threading.Thread.CurrentPrincipal are set by the Forms Authentication
module automatically and I don't have to worry about it. The reason I had to
do it in the Login event handler is because the cookie created in
SetAuthCookie() isn't available until the next request and I need to do
additional processing on the user prior to the login redirect. If I didn't,
the redirect would make lines [5] and [6] unnecessary.
See here for some more background:
http://msdn.microsoft.com/en-us/library/ms998372(dev10ide).aspx===