Losing WIF Claim with load balanced server

215 views Asked by At

I have an MVC4 C# project that uses WIF authentication. I am having a problem on a server with load balancing. I am getting an error accessing one of the claims when the server behind the load balancer changes.

This is strange because I do not lose that fact that I am authenticated. That indicates that my cookie is getting to the new server but the claim is missing for some reason.

I am adding a claim like this:

((ClaimsIdentity)HttpContext.User.Identity).AddClaim(new Claim("TheClaimName", "TheClaimValue"));

I think that perhaps the claim itself is not being persisted to the cookie. How do I 'save' this?

Here is my config file.

<system.identityModel>
    <identityConfiguration>
        <audienceUris>
            <add value="uri:someValue" />
        </audienceUris>
        <certificateValidation certificateValidationMode="None" />
        <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <trustedIssuers>
                <add thumbprint="AAAA3A088B9D2010333890138D64C2E66169DEEE" />
            </trustedIssuers>
        </issuerNameRegistry>
            <securityTokenHandlers>
            <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            </securityTokenHandlers>
    </identityConfiguration>
    </system.identityModel>
  <system.identityModel.services>
    <federationConfiguration >
        <cookieHandler requireSsl="true" name=".myCookieName" hideFromScript="true" path="/" domain="myDomain.com"/>
        <wsFederation passiveRedirectEnabled="true" issuer="https://login.server.com/issue/wsfed" realm="uri:someValue" requireHttps="true" />
    </federationConfiguration>
  </system.identityModel.services>
0

There are 0 answers