PC Review


Reply
Thread Tools Rate Thread

How to do forms authentication with cookieless=UseUri?

 
 
gnewsgroup
Guest
Posts: n/a
 
      25th Jan 2008
I googled "useuri", but nothing helpful turns up.

The forms authentication of my web application works perfectly if I
set

cookieless="UseDeviceProfile".

I want to test cookieless forms authentication, so in Web.config I
changed it to

cookieless="UseUri"

Apparently something else needs to be done in the code-behind if we do
UseUri, but I cannot find any documentation or helpful discussion
about this on the Web.

Any idea?

Thanks.
 
Reply With Quote
 
 
 
 
gnewsgroup
Guest
Posts: n/a
 
      25th Jan 2008
On Jan 25, 11:06 am, gnewsgroup <gnewsgr...@gmail.com> wrote:
> I googled "useuri", but nothing helpful turns up.
>
> The forms authentication of my web application works perfectly if I
> set
>
> cookieless="UseDeviceProfile".
>
> I want to test cookieless forms authentication, so in Web.config I
> changed it to
>
> cookieless="UseUri"
>
> Apparently something else needs to be done in the code-behind if we do
> UseUri, but I cannot find any documentation or helpful discussion
> about this on the Web.
>
> Any idea?
>
> Thanks.


Oh, I forgot to say what symptoms it has with cookieless=UseUri.

The symptom is: Right after a user logs in, he is immediately kicked
out to the same login page. Credentials are correct for sure.
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      25th Jan 2008
no codebehind changes usually are required except with redirects. you should
be using relative or "~" urls. links can also be a problem.

this is because cookieless changes the url to have a login ticket. say your
site is:

http://localhost/mysite/default.aspx

in cookieless it becomes

http://localhost/mysite/<login ticket>/default.aspx

if your redirect does not include the login ticket, then the user is logged
out. you can use cookiesless sessions, and the session ticket is appended to
the authenication ticket.

-- bruce (sqlwork.com)


"gnewsgroup" wrote:

> I googled "useuri", but nothing helpful turns up.
>
> The forms authentication of my web application works perfectly if I
> set
>
> cookieless="UseDeviceProfile".
>
> I want to test cookieless forms authentication, so in Web.config I
> changed it to
>
> cookieless="UseUri"
>
> Apparently something else needs to be done in the code-behind if we do
> UseUri, but I cannot find any documentation or helpful discussion
> about this on the Web.
>
> Any idea?
>
> Thanks.
>

 
Reply With Quote
 
gnewsgroup
Guest
Posts: n/a
 
      25th Jan 2008
On Jan 25, 12:11 pm, bruce barker
<brucebar...@discussions.microsoft.com> wrote:
> no codebehind changes usually are required except with redirects. you should
> be using relative or "~" urls. links can also be a problem.
>
> this is because cookieless changes the url to have a login ticket. say your
> site is:
>
> http://localhost/mysite/default.aspx
>
> in cookieless it becomes
>
> http://localhost/mysite/<login ticket>/default.aspx
>
> if your redirect does not include the login ticket, then the user is logged
> out. you can use cookiesless sessions, and the session ticket is appended to
> the authenication ticket.
>
> -- bruce (sqlwork.com)
>


Thanks. Our client is cookie-phobic, even if it is encrypted and only
contains the username (which is public info anyway) and some
timestamp. So, I thought maybe I can do cookieless.

But, after reading some articles online, I find that cookieless
session may even be worse because the session id directly displays
itself in the URL (at least it is much easier to steal).

So, I guess my question becomes this:

Given that cookies are not allowed, what's the most secure way of
doing authentication? I don't want to go for the classic-asp approach
of checking the session value of USERNAME (for example) on each and
every single page. I am using asp.net 2.0.
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      25th Jan 2008
you are confusing session and authentication. they are unrelated.

forms authentication create a login ticket and stores it in a cookie or the
url. session also creates a session ticket and stores it in a cookie or the
url. they can both use cookies, uri or be configured differently.

storing the login ticket in session just reduces the number of tickets sent
to the client.

cookie is slighty more secure (if you use https) because its not in the url.

the most secure is to not use forms authentication but rather a secure one
like kerberos or basic over https. then you store the login in the session,
and on every session fetch, check the the login matches the authenticated
user (thus preventing session hijacks)

-- bruce (sqlwork.com)


"gnewsgroup" wrote:

> On Jan 25, 12:11 pm, bruce barker
> <brucebar...@discussions.microsoft.com> wrote:
> > no codebehind changes usually are required except with redirects. you should
> > be using relative or "~" urls. links can also be a problem.
> >
> > this is because cookieless changes the url to have a login ticket. say your
> > site is:
> >
> > http://localhost/mysite/default.aspx
> >
> > in cookieless it becomes
> >
> > http://localhost/mysite/<login ticket>/default.aspx
> >
> > if your redirect does not include the login ticket, then the user is logged
> > out. you can use cookiesless sessions, and the session ticket is appended to
> > the authenication ticket.
> >
> > -- bruce (sqlwork.com)
> >

>
> Thanks. Our client is cookie-phobic, even if it is encrypted and only
> contains the username (which is public info anyway) and some
> timestamp. So, I thought maybe I can do cookieless.
>
> But, after reading some articles online, I find that cookieless
> session may even be worse because the session id directly displays
> itself in the URL (at least it is much easier to steal).
>
> So, I guess my question becomes this:
>
> Given that cookies are not allowed, what's the most secure way of
> doing authentication? I don't want to go for the classic-asp approach
> of checking the session value of USERNAME (for example) on each and
> every single page. I am using asp.net 2.0.
>

 
Reply With Quote
 
gnewsgroup
Guest
Posts: n/a
 
      26th Jan 2008
On Jan 25, 6:22*pm, bruce barker
<brucebar...@discussions.microsoft.com> wrote:
> you are confusing session and authentication. they are unrelated.
>
> forms authentication create a login ticket and stores it in a cookie or the
> url. session also creates a session ticket and stores it in a cookie or the
> url. they can both use cookies, uri or be configured differently.
>
> storing the login ticket in session just reduces the number of tickets sent
> to the client.
>
> cookie is slighty more secure (if you use https) because its not in the url.
>
> the most secure is to not use forms authentication but rather a secure one
> like kerberos or basic over https. then you store the login in the session,
> and on every session fetch, check the the login matches the authenticated
> user (thus preventing session hijacks)
>
> -- bruce (sqlwork.com)
>
>


Thank you very much for the clarification. Right now, I am storing
the authentication ticket in a cookie like so:

Session.Add("UserName", username);
FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, "someuserdatahere");
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(username,
false));

So, according to what you suggested, I could simply do:

Session.Add("authentication_ticket", encryptedTicket);

to stick it into the session and leave out the cookie part?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cookieless Forms Authentication - please help... studio60podcast@gmail.com Microsoft Dot NET 1 15th Jun 2006 01:47 AM
cookieless Forms Authentication - Please Help... studio60podcast@gmail.com Microsoft ASP .NET 0 11th Jun 2006 04:12 PM
Cookieless Forms Authentication Oscar Thornell Microsoft ASP .NET 1 11th May 2006 05:05 PM
Re: Cookieless forms authentication in Asp.Net 1.0? Daniel Fisher\(lennybacon\) Microsoft ASP .NET 0 30th Nov 2005 08:55 AM
Cookieless forms authentication in Asp.Net 1.0? Marcus Microsoft ASP .NET 0 29th Nov 2005 05:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:02 PM.