我需要实现非常简单的auth mechanizm,基本上有2个角色:Owners和Users.而且我认为拥有Enum就足够了.应用程序本身是SPA,通过Asp.net核心实现webapi.我看到了文章 - 如何使用EF Identity实现它,但是他们的模型看起来比我实际需要的复杂得多,并且EF面向SQL db,我使用mongo.所以我的用户看起来像:
class UserModel{
Id,
Token,
Roles: ["Owners", "Users"],
...
}
Run Code Online (Sandbox Code Playgroud)
那么我需要实现哪些接口并添加到DI才能使用
[Authorize]和[Authorize(Roles="Users")]属性,并且它们根据我在标头中发送的令牌正常工作?
c# authentication authorization asp.net-core-mvc asp.net-core