I have added the Authentication attribute on controller classes which are for admin purposes like adding, removing categories and product. All such controllers(ManageCategory, ManageProduct) are decorated with following :-
[Authorize(Roles = "Administrator")]
These controllers have Upload and Remove action methods which are invoked by jquery from the rendered view. Since client script don't use the URL or postback, I am bit skeptical if someone can bypass the controller authorization. These action methods are very sensitive because it provides the ability to remove a file on server. Following is the code from Remove action method.
[HttpPost]
public ActionResult Remove(string fileName)
{
string completFileName = Server.MapPath("~" + fileName);
System.IO.File.Delete(completFileName);
return Json(true);
}
Though this action method resides in a Controller with Authorization, Can someone still reach it without logging-in. Should i be worried and do something else or one will always need to be authorized as administrator before accessing this ?.
Authorizeconstruct for controllers. The answer is either "trust them" or go read their sourceRemovemethod would be invoked depends 100% on howAuthorizeworks. So basically, if you don't trust it go confirm it works correctly by reading the source