I have installed the Thinktecture.IdentityModel.Core package.
Suppose I've registered my custom implementation of AuthorizationManager
in web.config file.
public class AuthorizationManager : ClaimsAuthorizationManager {
public override Boolean CheckAccess(AuthorizationContext context) {
// authorization implementation
}
}
There are a permissions defined in the application db for user roles. So that User
might have Read
permission for Blogs
and Arts
resources if it is in a BasicUser
role.
The workflow as I see it:
- at login you make a db query to fetch all action-resources pairs from all assigned roles for the authenticated user
- then you gotta add claims (based on the db query result) to the identity
ClaimsAuthorizationAttribute
makes a call to theClaimsAuthorizationManager
ClaimsAuthorizationManager
internally checks the authentication cookie with claims from the step 2
Am I right?
Or am I supposed to do a database permission lookup inside the CheckAccess
method? Will this work on a per-request basis?
Howcome I transform/attach the db-fecthed set of action-resources into identity claims?