我们正在运行一个经典的asp网站,并希望与新开发的MVC应用程序一起使用。我们想利用经典asp应用程序中的身份验证来进行MVC应用程序。
我们的想法是,当用户登录经典asp应用程序时,它将发出一种auth cookie,该cookie使用我们自己的加密方法进行加密。Cookie将包含用户身份信息。
然后用户可以使用此auth cookie浏览MVC应用程序。 MVC应用程序将检查cookie是否存在并对其进行验证。 如果无效,则重定向到经典asp登录页面。
因此,我考虑自定义OWIN cookie身份验证以使用自己的身份验证逻辑。 我尝试实现CookieAuthenticationProvider,但不知道在哪里放置我的逻辑。
CookieAuthenticationProvider有一个OnValidateIdentity方法,但似乎不是提取cookie并验证其有效性的正确位置。
谢谢。 Jason.
我们的想法是,当用户登录经典asp应用程序时,它将发出一种auth cookie,该cookie使用我们自己的加密方法进行加密。Cookie将包含用户身份信息。
然后用户可以使用此auth cookie浏览MVC应用程序。 MVC应用程序将检查cookie是否存在并对其进行验证。 如果无效,则重定向到经典asp登录页面。
因此,我考虑自定义OWIN cookie身份验证以使用自己的身份验证逻辑。 我尝试实现CookieAuthenticationProvider,但不知道在哪里放置我的逻辑。
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并验证其有效性的正确位置。
谢谢。 Jason.