I have a 3 tier MVC solution: MVC Web - Business Layer - Data Access Layer
I have custom tables for users and groups in a database back-end, the user groups are mapped to a custom permission structure. The authentication needs to check for presence of the user and the authorisation needs to verify what the user can do based on their permissions.
I can perform the authentication and authorization by implementing a custom AuthorizeAttribute and asking the service level if the HttpContext.User.Identity.Name exists in the user table and also verify the user permissions based on the controller and action.
However, the service level needs to authorise the user again when being called from the action in the controller. This allows finer control over what the user can and can't do - for example, there are some fields that are read-only or hidden depending on the user group membership.
The issue being that I will end up authenticating and authorizing the user both in the AuthorizeAttribute of the controller action and from within the controller action itself (via the service level).
This is a design issue more than anything else but wanted to see if I am approaching the problem in the best way!