forms authentication, cookieless?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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]
    >-----Original Message-----
    >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%[/url]
    5d;Q311568) , 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
    >
    >
    >.
    >
    Fredrik Normén NSQUARED2 Guest

  4. #3

    Default 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

  5. #4

    Default Re: forms authentication, cookieless?

    You can't use FormsAuthentications without cookies.

    /Fredrik Normén NSQUARED2
    [url]http://www.nsquared2.net[/url]

    >-----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 the
    authentication ticket.
    >It is this latter I need to figure out, the former is
    easy.
    >
    >Thanks,
    >
    >Lauchlan M
    >
    >
    >.
    >
    Fredrik Normén www.NSQUARED2.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139