What is the claims in ASP .NET Identity

后端 未结 3 1195
面向向阳花
面向向阳花 2020-11-28 17:50

Can somebody please explain, what the claim mechanism means in new ASP.NET Identity Core?

As I can see, there is an AspNetUserLogins table, which contai

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 18:06

    There are two types of authentication in ASP.Net identity.

    1. Role based
    2. Claim based

    You can either use one of them or both at the same time. Use role based when you have very defined things. For example you create two rolea teacher and student. Only teacher can add subjects. So you assigned teacher role to those users whose you want to have access to add subjects.

    Claim based is more flexible. Suppose you have a requirement some students can also add subjects. In this case you have to create one more role who can be student and access to add subject. But if you are using claim based it would be very easy. Just create claim like addSubject and assign it to any user whise you want to access to add aubject.

提交回复
热议问题