我正在將舊的現有Web窗體站點配置爲多租戶環境。一個要求是能夠與多個客戶端ADFS集成。 我跟着this post已經成功實現了一個支持多個ADFS的MVC應用程序。不過,我仍然遇到一個問題, ,這是不能與MVC應用程序重現。在我的Web表單網站中,只有第一個註冊的ADFS提供程序成功。第二個總是 在認證並返回到我的網站後發生SignatureVerificationFailedException(異常發生在我身邊)。 這是無論我在OWIN啓動配置中使用app.Map(...)還是app.Use(...)。
我試圖將我的網站轉換爲Web應用程序,但結果相同。我想這與WEB FORMS中處理請求的方式有關,它與MVC不同。
我應該以某種不同的方式處理中間件映射嗎?
我錯過了什麼?
或者這是根本不可能的......ASP.NET Web Forms站點 - 使用OWIN與多個ADFS集成KATANA
這裏是我的OWIN啓動配置:
app.Properties["Microsoft.Owin.Security.Constants.DefaultSignInAsAuthenticationType"] = Config.ExternalAuthentication.Cookie;
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = Config.ExternalAuthentication.Cookie,
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive
});
string wreply = Config.ExternalAuthentication.Wreply;
string wtrealm = Config.ExternalAuthentication.Wtrealm;
List<Company> adfsCompanies = BL.GetCompaniesWithADFS();
app.Map("/Public/Login.aspx", configuration =>
{
foreach (Company company in adfsCompanies)
{
//configure middleware
var middleware = new WsFederationAuthenticationOptions()
{
MetadataAddress = company.ADFSMetadataUrl,
AuthenticationType = company.TenantName,
Caption = company.Name,
Wreply = wreply,
Wtrealm = wtrealm,
BackchannelCertificateValidator = null
};
//add to pipeline
configuration.UseWsFederationAuthentication(middleware);
}
});
這裏是我的挑戰要求:
context.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = callbackUrl },
provider);
response.StatusCode = 401;
response.End();
不管我做什麼,只第一個註冊的ADFS中間件成功了,不管是哪一個。我也嘗試將中間件附加到不同的流水線階段,但沒有成功。
在此先感謝您的幫助!
非常感謝@Tratcher。你的回答並沒有給出完整的解決方案,但它使我朝着正確的方向前進。爲了讓問題保持簡潔清晰,我會給出更多的答案 – Vladislav