2016-01-20 46 views
1

的示例應用程序可以在這裏找到 - >https://github.com/Azure-Samples/active-directory-dotnet-webapp-wsfederation天青樣品 - Web應用程序-WSFederation-DOTNET的

應用程序使用Microsoft.Owin,這就是我期待:

  1. 用戶瀏覽到您的應用程序。

  2. 你的應用重定向匿名用戶在天青AD進行身份驗證,發送指示對realm參數的應用的URI一個WS聯盟協議請求。該URI應該與單點登錄設置中顯示的App ID URI匹配。

  3. 請求被髮送到你的租戶WS聯盟端點,例如:https://login.windows.net/solexpaad.onmicrosoft.com/wsfed

  4. 用戶會看到一個登錄頁面,除非他或她已經具備了在Azure AD租戶有效的cookie。

  5. 當認證時,一個SAML令牌在HTTP POST爲與WS聯盟響應該應用程序的URL返回。要使用的URL在單點登錄設置中指定爲回覆URL。

  6. 的應用處理此響應,驗證所述令牌是否由可信發行者(天青AD)簽字,並確認該標記仍然是有效的。

我的問題:

一個SAML令牌通過HTTP POST返回的認證後。我如何查看SAML響應?目前,當我在POST後查看HttpContext時,沒有任何內容。

感謝您的任何幫助。

回答

2

在App_Start/Startup.Auth.cs,你應該能夠獲得訪問令牌。 我已添加SecurityTokenReceived功能:

app.UseWsFederationAuthentication(
    new WsFederationAuthenticationOptions 
    { 
     Wtrealm = realm, 
     MetadataAddress = metadata, 
     Notifications = new WsFederationAuthenticationNotifications 
      { 
       AuthenticationFailed = context => 
       { 
        context.HandleResponse(); 
        context.Response.Redirect("Home/Error?message=" + context.Exception.Message); 
        return Task.FromResult(0); 
       }, 
       SecurityTokenReceived = context => 
       { 
        // Get the token 
        var token = context.ProtocolMessage.GetToken(); 
        return Task.FromResult(0); 
       } 
      } 
     }); 
+0

Thanks !!我在ProtocolMessage中找到它。我假設RequestSecurityTokenResponse是有效的SAML? – Villain

+0

@Villain,看看解釋:https://access.redhat.com/documentation/en-US/Fuse_ESB/4.4.1/html/Web_Services_Security_Guide/files/WsTrust-Demo-Messages.html – Thomas

+0

感謝鏈接 – Villain