简体   繁体   中英

Asp.net Identity 2.x without Claims

I have a webpage that doesnt want/need third party logins and i dont want to pollute the database with unused tables (afaik claims are stored in its own table), Is it possible to use Identity 2.x with only User and Roles functionality? I can only find implementations (through google search) with only the User part, like this one .

I could certainly use that and create a Role table, but if i do that then could not use this:

[Authorize(Roles = "UserType1")]

Edit: i think claims are only needed for third party login, correct me if i am wrong

Claims are not needed for third-party logins. Claims are just bits of information stored in auth-cookie when user is logged in.

No, you can't have Identity framework without claims, as it sets the principal to be ClaimsPrincipal . But if you don't need/want claims, you just don't have to use it anywhere. And authentication through roles will still work. If you don't want to have UserClaims table in database, you'll have to implement your own user store that does not have claims table. However, I think this is too much effort just not to have an empty table in a db.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM