[英]Mixing Owin Asp.Net Identity Cookie Authentication with Owin OpenId Authentication
[英]ASP.NET OWIN Custom Cookie Authentication
我們正在運行一個經典的ASP Web應用程序,並希望它可以與新開發的MVC應用程序一起使用。 我們想在MVC應用程序中使用經典ASP應用程序的身份驗證。
這個想法是當用戶登錄到經典的asp應用程序時,它將發出某種身份驗證cookie,該cookie用我們自己的方法加密。 Cookie將包含使用身份。
客戶端然后瀏覽到MVC應用程序以及此身份驗證cookie。 MVC應用程序將檢查cookie是否存在並對其進行驗證。 有了它,就不能重定向到經典的asp登錄頁面。
因此,我正在考慮自定義OWIN Cookie身份驗證以使用我自己的身份驗證邏輯。 我試圖實現CookieAuthenicationProvider,但是我不知道將邏輯放在哪里。
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieName = ".classicauth",
CookieSecure = CookieSecureOption.SameAsRequest,
CookieHttpOnly = true,
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = context => {
//?? where I can extract the cookie and validate it??
context.RejectIdentity();
return Task.FromResult<int>(0);
},
OnApplyRedirect = context => {
context.Response.Redirect("classic_asp_login_url");
}
}
});
CookieAuthenticationProvider具有OnValidateIdentity,但是似乎不是提取Cookie並對其進行驗證的正確位置。
謝謝。 傑森
在這種情況下,我還沒有對自己進行自我測試。 但是CookieManager為我工作。
OnValidateIdentity = context => {
var cookie = context.Options.CookieManager.GetRequestCookie(context.OwinContext, context.Options.CookieName);
context.RejectIdentity();
return Task.FromResult<int>(0);
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.