2016-12-02 6 views
1

http://www.wiktorzychla.com/2012/09/forms-authentication-revisited.htmlのコードを使用して、既存のAsp.Net 3.5 Webサイトと連合認証を統合しようとしました。問題はfam.IsSignInResponse(request)がSTS(AD FS)からの有効な応答を取得した後でもfalseを返しています。 GetClaims()は、別のクラスライブラリにあるので、わずかに変更されています。同じコードが別のテストアプリケーションで動作しています。私はそれが間違っているのか分からない、助けてください。 下記のコードをご覧ください。STSの応答WSFederationAuthenticationModule IsSignInResponseは常に偽です

public List<ClaimEntity> GetClaims() 
     { 
      logger.Info("Started executing GetClaims()"); 
      List<ClaimEntity> claims = new List<ClaimEntity>(); 
      // sam is configured in web.config 
      var sam = FederatedAuthentication.SessionAuthenticationModule; 
      logger.Info("Declaring sam"); 
      // fam is not 
      var fam = new WSFederationAuthenticationModule(); 
      logger.Info("Declaring fam"); 
      //fam.FederationConfiguration = FederatedAuthentication.FederationConfiguration; 
      fam.ServiceConfiguration = FederatedAuthentication.ServiceConfiguration; 
      logger.Info("Assigning ServiceConfiguration to fam"); 
      var request = thisContext.Request; 

      // is this the response from the STS 
      if (!fam.IsSignInResponse(request)) 
      { 
       // no 
       logger.Info("fam.IsSignInResponse => No"); 
       // the STS 
       fam.Issuer = _IssuerSTSSpec.Issuer; 
       logger.Info("IssuerUrl= " + _IssuerSTSSpec.Issuer); 
       // the return address 
       fam.Realm = thisContext.Request.Url.AbsoluteUri; 
       logger.Info("Assigning fam.Realm= " + thisContext.Request.Url.AbsoluteUri); 
       logger.Info("Creating SignInRequest..."); 
       var req = fam.CreateSignInRequest(string.Empty, null, false);     
       logger.Info("Redirecting to the issuer..."); 
       logger.Info("Request to STS: "+ req.WriteQueryString().ToString()); 
       // go to STS 
       thisContext.Response.Redirect(req.WriteQueryString()); 

      } 
      else 
      { 
       // yes 
     ----------- 
     ----------- 

      } 
      logger.Info("Returning the claims"); 
      return claims; 
     } 

答えて

0

最後に私はそれを理解しました。 これは、AD FSとフォーム認証で作成された信頼に関する問題でした。

詳しくは、メタデータxmlのEndpointReferenceは、Webアプリケーション(SP)のドメイン名、つまりhttps://example.comにすぎません。このサイトは、ホームページ(Default.aspx)でAD FS応答を受信して​​いましたが、設定したページ(Login.aspx)ではありませんでした。 WSFederationAuthenticationModule IsSignInResponseがfalseであるため、ホームページがレスポンスを受信すると、レスポンスをサインインではなくフォーム認証コンフィグレーションごとにログインページにリダイレクトします。ログインページは再びAD FS URLにリダイレクトされます。これは再帰的に起こっていた。

エンドポイント参照をhttps://example.com/Login.aspxに変更し、期待どおりに動作するようになりました。

関連する問題