What is everyone doing to handle security (retrieval and modification) of individual records in an ASP.NET MVC application? This application has a Service/Business layer and a Data Access layer that are completely separate from the Web user interface. I am already using the membership and roles providers to handle authentication and authorization for specific areas/features in my application, but now I need to secure individual records.
For example, say Bob can create and edit his own FooBar records. I want to ensure that other users cannot view or edit Bob's records. I want to protect against URL manipulation and/or programming mistakes. We may also want to allow Bob to share his FooBars with other users, allowing them to view but not edit his records.
There are several approaches I have come up with:
- Do the security checks in the Data Access layer, directly in the retrieval and modification queries.
- Check security in the Service layer, performing extra security queries before proceeding with the Business logic.
- Create a Security layer that exists between the UI and the Service layer. The UI would make all requests through the Security layer.
- Use aspect-oriented programming (AOP). Create security aspects and decorate the Service layer methods with security attributes.
I've done security in the Data Access layer (in the queries) in previous projects, and it always turns into a mess. I would like to know what everyone else is doing, and what frameworks you are using to help you (AOP frameworks.)