2012-11-21 19 views
2

我有這種情況。如何在同一頁面上登錄WIF聯合?

  1. RP被動聯邦2.
  2. 定義STS爲用戶/密碼認證

    一切工作正常。到目前爲止,用戶會按下登錄鏈接,這將進入一個限制區域,因此聯邦安全性被觸發,登錄屏幕出現。它會提示他寫出憑證,然後處理請求等。

    現在我需要在同一頁面(默認頁面)上創建登錄(用戶/密碼)文本框。如何在不重定向到登錄頁面的情況下實現聯合登錄操作?應該(或可以)我使用FederatedPassiveSignIn控件嗎?如果是這樣,怎麼樣?

+0

身份驗證發生在STS中。在您的網站中擁有用戶名/密碼文本框的目的是什麼?該控件將簡單地將您重定向到STS。 –

+0

相信我,這不是我的想法。這是我的僱主要求的。網站的其他部分應該像現在一樣停留在被動聯盟(當漫遊通過網站的禁止鏈接時重定向)。但仍然文本框現在被放置在Site.Master(是的,我知道)。同時我發現,FederatedPassiveSignIn不會有什麼用處。我正在嘗試手動處理請求/響應。 – SmartK8

回答

1

你能證明未受保護的目標網頁上的登錄框,如果IsAutheticated是假的,然後將消息發送到定製STS登錄頁面進行加密的證書或什麼,然後記錄在幕後,重定向回你的應用。以正常方式使用令牌。

但是,如果用戶未通過身份驗證並在登錄頁面後面書籤頁,他們將被重定向到STS。

+0

這是我的備用想法,如果一切都失敗了。但是我會在經過一些更多的測試之後提出我自己的答案(我相信正確的直接方法)。但我會在那時接受你的回答。因爲它是「一個」解決方案,我更願意接受別人的回答。 – SmartK8

0

對於任何感興趣的人(我懷疑有人實際上是),我已經解決了它 - 基本上 - 模擬登錄頁面做什麼。

// makes credentials validation, and creates IClaimsPrincipal with the acquired claims 
IClaimsPrincipal principal = LoginHelper.SignIn(editEmail.Value, editPassword.Value); 

// retrieves the instance of the STS (in this case my custom STS) 
TrustedSecurityTokenService service = (TrustedSecurityTokenService) TrustedSecurityTokenServiceConfiguration.Current.CreateSecurityTokenService(); 

// creates the request manually to point to my original page (or whatever page you desire) 
SignInRequestMessage request = FederatedAuthentication.WSFederationAuthenticationModule.CreateSignInRequest(Guid.NewGuid().ToString(), "http://page/i/want/to/go/after/the/validation.aspx", true); 

// processes first the request... 
SignInResponseMessage response = FederatedPassiveSecurityTokenServiceOperations.ProcessSignInRequest(request, principal, service); 

// ...then the response is processed, and redirected to URL above 
FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(response, Response); 

這創建了cookie,並且主體不是IsAuthenticated。就好像它是通過登錄頁面進行處理一樣(至少它看起來像預期的那樣工作)。

+0

這幫了我!謝謝@ SmartK8。 – nocarrier

相關問題