microsoft.identityModel迁移到system.Identity模型

时间:2015-07-10 07:21:51

标签: asp.net-mvc cookies wif

我目前在网上的STS配置如下,

<microsoft.identityModel>    
<service saveBootstrapTokens="true">
  <audienceUris mode="Never"/>
  <federatedAuthentication>
    <wsFederation passiveRedirectEnabled="true" issuer="https://fs.mysite.net/adfs/ls" realm="https://myweb.cloudapp.net/" reply="https://myweb.cloudapp.net/Account/FederatedResult" requireHttps="false"/>
    <cookieHandler requireSsl="false"/>
  </federatedAuthentication>
  <serviceCertificate>
    <certificateReference x509FindType="FindBySubjectName" findValue="*.mydomain.net"/>
  </serviceCertificate>
  <applicationService>
    <claimTypeRequired>
      <claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" optional="true"/>
      <claimType type="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" optional="true"/>
      <claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" optional="true"/>
    </claimTypeRequired>
  </applicationService>
  <issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    <trustedIssuers>
      <add thumbprint="a5069c80a92e7a49937bba9bc25a85a57b4bbc74" name="https://fs.myweb.net/adfs/services/trust"/>
    </trustedIssuers>
  </issuerNameRegistry>
  <certificateValidation certificateValidationMode="None"/>
</service>

我需要如下所述引入MachineKeySessionSecurityTokenHandler(在我需要通过mahcinekey强制执行cookie加密的Web场环境中)

<system.identityModel>
  <identityConfiguration>
    <securityTokenHandlers>
      <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </securityTokenHandlers>
  </identityConfiguration>
</system.identityModel>

但是标签在system.identityModel中不可用。此外,federatedAuthentication标记也会出错。有人可以帮我将microsoft.identityModel迁移到system.identityModel版本。

1 个答案:

答案 0 :(得分:0)

您是否将以下内容放在web.config的顶部?

<configuration>
  <configSections>
    <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />