在我看到的默认AccountController中创建
public AccountController()
: this(Startup.UserManagerFactory(), Startup.OAuthOptions.AccessTokenFormat)
{
}
Run Code Online (Sandbox Code Playgroud)
在Startup.Auth.cs中我看到了
UserManagerFactory = () =>
new UserManager<IdentityUser>(new UserStore<IdentityUser>());
Run Code Online (Sandbox Code Playgroud)
似乎UserStore的实现来自Microsoft.AspNet.Identity.EntityFramework.
因此,要自定义身份验证,我必须实现自己的UserStore版本
class MYSTUFFUserStore<IdentityUser> : UserStore<IdentityUser>
{
}
Run Code Online (Sandbox Code Playgroud)
并覆盖方法,然后在Startup.Auth.cs中执行此操作
UserManagerFactory = () =>
new UserManager<IdentityUser>(new MYSTUFFUserStore<IdentityUser>());
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种自定义身份验证的正确方法.
我正在使用Visual Studio 2013构建web api,并希望使用OWIN中间件和持有者令牌进行身份验证.但是我已经有了一个数据库,并且不想使用Microsoft的新Identity框架作为它自动生成的大多数表和列,我根本不需要.
任何人都可以指出我如何应用此类身份验证的正确方向,而无需使用Microsoft身份框架?