Ask a Question related to ASP.NET Security, Design and Development.
-
Lauchlan M #1
forms authentication, cookieless?
Hi.
I want a login framework that uses the ASP.NET web.config / forms
authentication security schema (including roles in principals etc), but
operates cookieless.
What this means is I have to construct the authentication cookie, and I
guess I have to pass it around as a url variable eg something like (from
[url]http://www.codeproject.com/aspnet/cookieless.asp[/url] )
<<
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
//create a valid ticket for forms authentication
tkt = new FormsAuthenticationTicket(1, userName, DateTime.Now,
DateTime.Now.AddMinutes(30), false, "your custom data");
//get the string representation of the ticket
cookiestr = FormsAuthentication.Encrypt(tkt);
//redirect to the return URL using the cookie in the address field
//In the web.config, we called out auth. ASPXFORMSAUTH2, so set that value
string strRedirect = Request["ReturnUrl"] + "?.ASPXFORMSAUTH2=" + cookiestr;
Response.Redirect(strRedirect, true);The other way suggested on that page - using an authenticated session>>
variable to confirm if a user is authenticated or not - doesn't work because
it doesn't tie in with the ASP.NET web.config schema and hence does not
provide directory level security unless one codes it manually by checking
the filepath in one of the Global.asax event handlers. The web.config file
will always bounce you back to Login.aspx because you never 'officially'
logged in, unless you get rid of the web.config authentication and
authorisation.
But passing the cookie around like that is really messy, and I'm not sure it
accomplishes anything since it is encrypted and I'm not sure anything reads
it or uses it in that form. Presumably you'd have to unpack it in one of the
the global.asax event handlers (eg the AuthenticateRequest one). It would be
much nicer if I could make the authentication ticket a session variable and
ASP.NET knew to look for it there when it is configured that way.
I could also use the Mobile stuff for forms authentication
([url]http://support.microsoft.com/default.aspx?scid=kb;%5bLN%5d;Q311568[/url]) , but
this does not appear to have a redirect method, only a redirect from login
method.
So I am fishing for a best method to tie in a cookieless login framework
with the ASP.NET forms authentication framework, which seems heavily
premised on using a cookie for the authentication ticket.
Any suggestions?
Lauchlan M
Lauchlan M Guest
-
Accessing htm files without authentication (forms authentication)
I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But... -
ASP.Net Forms authentication with basic authentication popup
Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user... -
Form Authentication with cookieless browser
This is a definition for Form Authentication from MSDN : "The Forms authentication provider is an authentication scheme that makes it possible for... -
Forms authentication then redirection to a secure web with NT authentication?
Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've... -
Authentication ticket, cookieless, forms authentication?
Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the... -
Fredrik Normén NSQUARED2 #2
forms authentication, cookieless?
You can set the sessesionState element's cookieless
attribute to false in the configuration file. If
cookieless is set to false the session id will be added
to the URL.
<configuration>
<system.web>
<sessionState mode="Inproc"
cookieless="false"
timeout="20"/>
</sessionState>
</system.web>
</configuration>
/Fredrik Normén NSQUARED2
[url]http://www.nsquared2.net[/url]
web.config / forms>-----Original Message-----
>Hi.
>
>I want a login framework that uses the ASP.NETprincipals etc), but>authentication security schema (including roles inauthentication cookie, and I>operates cookieless.
>
>What this means is I have to construct thesomething like (from>guess I have to pass it around as a url variable egDateTime.Now,>[url]http://www.codeproject.com/aspnet/cookieless.asp[/url] )
>
><<
>FormsAuthenticationTicket tkt;
>string cookiestr;
>HttpCookie ck;
>
>//create a valid ticket for forms authentication
>tkt = new FormsAuthenticationTicket(1, userName,address field>DateTime.Now.AddMinutes(30), false, "your custom data");
>
>//get the string representation of the ticket
>cookiestr = FormsAuthentication.Encrypt(tkt);
>
>//redirect to the return URL using the cookie in theso set that value>//In the web.config, we called out auth. ASPXFORMSAUTH2,+ "?.ASPXFORMSAUTH2=" + cookiestr;>string strRedirect = Request["ReturnUrl"]authenticated session>Response.Redirect(strRedirect, true);>>>>
>The other way suggested on that page - using andoesn't work because>variable to confirm if a user is authenticated or not -hence does not>it doesn't tie in with the ASP.NET web.config schema andmanually by checking>provide directory level security unless one codes itThe web.config file>the filepath in one of the Global.asax event handlers.never 'officially'>will always bounce you back to Login.aspx because youauthentication and>logged in, unless you get rid of the web.configand I'm not sure it>authorisation.
>
>But passing the cookie around like that is really messy,sure anything reads>accomplishes anything since it is encrypted and I'm notunpack it in one of the>it or uses it in that form. Presumably you'd have toAuthenticateRequest one). It would be>the global.asax event handlers (eg thesession variable and>much nicer if I could make the authentication ticket athat way.>ASP.NET knew to look for it there when it is configuredauthentication>
>I could also use the Mobile stuff for forms5d;Q311568) , but>([url]http://support.microsoft.com/default.aspx?scid=kb;%5bLN%[/url]redirect from login>this does not appear to have a redirect method, only alogin framework>method.
>
>So I am fishing for a best method to tie in a cookielessseems heavily>with the ASP.NET forms authentication framework, which>premised on using a cookie for the authentication ticket.
>
>Any suggestions?
>
>Lauchlan M
>
>
>.
>Fredrik Normén NSQUARED2 Guest
-
Lauchlan M #3
Re: forms authentication, cookieless?
<<
You can set the sessesionState element's cookieless
attribute to false in the configuration file.Surely you mean set cookieless to true?>>
This is what I do currently.
But this only handles passing the sessionID, not the authentication ticket.
It is this latter I need to figure out, the former is easy.
Thanks,
Lauchlan M
Lauchlan M Guest
-
Fredrik Normén www.NSQUARED2.net #4
Re: forms authentication, cookieless?
You can't use FormsAuthentications without cookies.
/Fredrik Normén NSQUARED2
[url]http://www.nsquared2.net[/url]
authentication ticket.>-----Original Message-----
><<
>You can set the sessesionState element's cookieless
>attribute to false in the configuration file.>>>>
>Surely you mean set cookieless to true?
>
>This is what I do currently.
>
>But this only handles passing the sessionID, not theeasy.>It is this latter I need to figure out, the former is>
>Thanks,
>
>Lauchlan M
>
>
>.
>Fredrik Normén www.NSQUARED2.net Guest



Reply With Quote

