We are considering the Hot Towel SPA template for an ASP.NET MVC a new project, but are not sure how to filter & secure user specific data. Our project would be ASP.NET MVC based with EntityFramework.
Consider a service that allows people to store sales information for different companies, each with one or more locations.
- When a store manager logs in, he should only see his store's sales.
- When a regional manager logs in, he should only see the stores in his region.
- When the CEO logs in, he should be able to see all of the stores.
This business logic could be handled within the Javascript on client side, but it would seem that it would be easy to bypass with browser developer tools, Fiddler or the like. By manipulating HTTP request strings (since it's OData based), they could see data for other stores in their company, and potentially stores for other companies.
It would be nice to say on the client-side:
var query1a = EntityQuery.from("Customers")
.where("CompanyName", "startsWith", "A");
and it return results only for the current user, and not for the entire db.
Any suggestions/examples/tutorials on how to accomplish this on the server?
Would it make sense to store this "filter" logic in session variables? So for the query above:
(something to the effect of)
[HttpGet]
public IQueryable<Customer> Customers() {
return _contextProvider.Context.Customers.Where(x=> x.CompanyID == Session['CompanyID'];
}