How is everyone else protecting against this vulnerability? In an MVC application that is separated in multiple logical layers i.e. Presentation Layer (MVC) > Service Layer > Business Layer > Repository Layer. Is it just a matter of performing a check at the controller level e.g.
[Authorize]
public class AccountsController : Controller
{
[HttpGet]
public ActionResult Details(long accountNumber)
{
var account;
//account = Call Service Layer to get the account.
if (account.UserId != User.Identity.GetUserId())
{
return new HttpUnauthorizedResult("User is not Authorized.");
}
}
}
Is there any particular design pattern I can use to improve this design? Furthermore wouldn't it be better to perform this check in my service layer?