随着Core 1.1遵循@ blowdart的建议并实施了自定义中间件:
它的工作方式如下:
这有点适用于2.0,除了如果令牌无效(上面的步骤2)并且从未添加声明我得到"没有指定authenticationScheme,并且没有找到DefaultChallengeScheme."
所以现在我正在读取2.0中的auth更改:
https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/identity-2x
在ASP.NET Core 2.0中我做同样的事情的正确途径是什么?我没有看到做真正的自定义身份验证的示例.
在ASP.NET Core 2.0中,.UseAuthentication()中间件有一个重大更改,不再允许此处提到的旧语法工作.
新版本似乎在addAuthentication中处理配置,但我无法在任何地方找到有关如何更改指定自定义登录和注销URL的旧代码的任何详细信息.
services.AddAuthentication(o =>
{
// Where can I specify this?????
var opt = new CookieAuthenticationOptions()
{
LoginPath = "/api/login",
LogoutPath = "/api/logout",
};
o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激...