I'm currently designing a system using asp.net core and I'd like to implement claims based authorization, but one particular part is confusing me.
When a claim is made the claim will include the type and the value and optionally an issuer. In a handler this claim and the issuer may be checked before access is confirmed.
However this issuer is not stored in the Identity db, so how does the handler then check the issuer?
Am I misunderstanding how this all works? My understanding was that a user makes a claim of some type, that their claim is of a certain value and the issuer is the validator of the claim type actually having that value for that user.
The handler will check the value and may check the issuer but it can't when the db does not store it. I don't understand the point of the issuer then.
I'd like the user to have a collection of claims, including who/what verifies those claims and for the application to at any time be able to verify those claims.
Please help me understand.
I have tested this as so:
- Using a asp.net core app with Identity.
- Register a user.
- Add a claim to a user that includes a type, a value and an issuer. (for example, EmployeeNumber, 312, Microsoft.
- Add an [Authorize(Policy="MicrosoftEmployeesOnly")] on a controller/action to restrict access.
- Add the policy into services in StartUp.cs with a requirement.
- Add requirement code that has a handler that checks the user has a claim of type EmployeeNumber, has a value and it is issued by Microsoft.
- Login and the users claims will have been loaded in from the db into the identity.
- The handler will fail to validate the user because the issuer (Microsoft) has been lost and now just says Local Authority.
The only thing I can think of here, is once the claim is added in to the db, it is considered validated by Microsoft and now held by the app (Local Authority) on behalf of Microsoft.
If that's true then:
- Why check the issuer at all in any handler?
- How do you revoke a claim?
I would prefer to be able to optionally go to that issuer and check the claim whenever I want, meaning the issuer could revoke/invalidate the claim. The employee makes the claim they have an employee number at Microsoft and initially Microsoft validate that. Some time later, Microsoft kick the employee out and on their system remove him. The app should be able to check with Microsoft each time the user logs in to see if the claim is valid. In this case it would not be valid any more.
Am I going slightly mad?