2011-10-20 8 views
1

ロードバランサでサイトを実行する必要があるため、セッショントークンハンドラを次のものに置き換える必要がありました。ロードバランサを使用して開始して信頼する側

public class WebFarmSessionSecurityTokenHandler : SessionSecurityTokenHandler 
{ 
    public WebFarmSessionSecurityTokenHandler(X509Certificate2 protectionCertificate) 
     : base(CreateRsaTransforms(protectionCertificate)) 
    { } 

    private static ReadOnlyCollection<CookieTransform> CreateRsaTransforms 
     (X509Certificate2 protectionCertificate) 
    { 
     var transforms = new List<CookieTransform>() 
         { 
          new DeflateCookieTransform(), 
          new RsaEncryptionCookieTransform(protectionCertificate), 
          new RsaSignatureCookieTransform(protectionCertificate), 
         }; 

     return transforms.AsReadOnly(); 
    } 
} 

次に、web.configを次のように修正しました。これをやった後

<microsoft.identityModel> 
    <service> 
... 
    <securityTokenHandlers> 
     <clear /> 
     <add type="MyAssembly.WebFarmSessionSecurityTokenHandler, MyAssembly"/> 
    </securityTokenHandlers> 
... 
    </service> 
</microsoft.identityModel> 

私の希望は私の証明書利用者がauthenicationを開始し、それがアクセスしていたものをノードまたはどのボックスに関係なく機能するであろうということでした。

現在、次のようになっています。SecurityTokenHandlerがセキュリティトークンを読み取るために登録されていません。

アイデア?

答えて

2
void onServiceConfigurationCreated(object sender, ServiceConfigurationCreatedEventArgs e) 
     { 
      List<CookieTransform> sessionTransforms = new List<CookieTransform>(new CookieTransform[] 
      { 
       new DeflateCookieTransform(), 
       new RsaEncryptionCookieTransform(e.ServiceConfiguration.ServiceCertificate), 
       new RsaSignatureCookieTransform(e.ServiceConfiguration.ServiceCertificate) 
      }); 

      SessionSecurityTokenHandler sessionHandler = new SessionSecurityTokenHandler(sessionTransforms.AsReadOnly()); 
      e.ServiceConfiguration.SecurityTokenHandlers.AddOrReplace(sessionHandler); 
     } 

上記は、global.asaxファイル内に配置する必要があります。アプリケーションの開始時に次のイベントが表示されます。

FederatedAuthentication.ServiceConfigurationCreated += onServiceConfigurationCreated; 

私はもはやそれをスロットにWebFarmSessionSecurityTokenHandlerや設定変更を必要としない。

関連する問題