How to do forms authentication with cookieless=UseUri?
How to do forms authentication with cookieless=UseUri?
am 25.01.2008 17:06:43 von gnewsgroup
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.
Re: How to do forms authentication with cookieless=UseUri?
am 25.01.2008 17:09:50 von gnewsgroup
On Jan 25, 11:06 am, 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.
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.
RE: How to do forms authentication with cookieless=UseUri?
am 25.01.2008 18:11:01 von brucebarker
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//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.
>
Re: How to do forms authentication with cookieless=UseUri?
am 25.01.2008 18:32:35 von gnewsgroup
On Jan 25, 12:11 pm, bruce barker
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//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.
Re: How to do forms authentication with cookieless=UseUri?
am 26.01.2008 00:22:01 von brucebarker
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
> 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//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.
>
Re: How to do forms authentication with cookieless=UseUri?
am 26.01.2008 05:38:28 von gnewsgroup
On Jan 25, 6:22=A0pm, bruce barker
wrote:
> you are confusing session and authentication. they are unrelated.
>
> forms authentication create a login ticket and stores it in a cookie or th=
e
> url. session also creates a session ticket and stores it in a cookie or th=
e
> url. they can both use cookies, uri or be configured differently.
>
> storing the login ticket in session just reduces the number of tickets sen=
t
> to the client.
>
> cookie is slighty more secure (if you use https) because its not in the ur=
l.
>
> 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 =3D
new FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(20), false, "someuserdatahere");
string encryptedTicket =3D FormsAuthentication.Encrypt(ticket);
HttpCookie cookie =3D new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(usernam e,
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?