Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single sign on in ASP.NET - cookie name, machineKey and what more?

I have two ASP.NET apps hosted on one server. Their configs have the same machineKey values and the authentication sections look as follows:

<authentication mode="Forms">
      <forms loginUrl="/_login/default.aspx" name=".MySingleAuth" />
    </authentication>

<authentication mode="Forms">
      <forms loginUrl="~/MySingle/LogOn/0" timeout="2880" name=".MySingleAuth"/>
    </authentication>

The single sign on (authentication in both applications using one cookie) still doesn't work. What am I missing?

Edit: The two apps are on our intranet, one under https://ip:84 and the other under https://ip:86 (where ip is an IP).

like image 457
agnieszka Avatar asked Nov 30 '10 09:11

agnieszka


1 Answers

For me, the following configuration for SingleSignOn worked:

<machineKey
  validationKey="818B77A6AFBF5E0B82B7FBE6F992E1733986DAEF81D1EB107B55D6F68EB6FEC6097349A9E37A407A6B5CF2FA1AB9327CA182A2C999A768C14B146036420203F9"
  decryptionKey="45798D54477D1D11BFC16733786AABB50E7FD5DDB3F8F46A"
  validation="SHA1"
/>

<authentication mode="Forms">
  <forms name=".ASPXAUTH" loginUrl="~/Login.aspx" protection="All" cookieless="UseCookies" enableCrossAppRedirects="true"/>
</authentication>
  1. Be sure the keys on the two applications are absolutely identical (validation and decryption)
  2. The cookie name must be the same
  3. SingleSignOn is only working if you are on the same domain (cookies).

Read this page, it helped me: http://www.codeproject.com/KB/aspnet/SingleSignon.aspx

like image 105
EvilMM Avatar answered Sep 21 '22 06:09

EvilMM