mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
37 lines
757 B
C#
37 lines
757 B
C#
using System.Web;
|
|
using System.Web.Helpers;
|
|
using System.Web.Mvc;
|
|
|
|
public class HomeController : Controller
|
|
{
|
|
// This is fine because of the global filter
|
|
[HttpPost]
|
|
public ActionResult Login()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// GOOD: Anti forgery token is validated
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult UpdateDetails()
|
|
{
|
|
return View();
|
|
}
|
|
}
|
|
|
|
public class AntiForgeryFilter : FilterAttribute, IAuthorizationFilter
|
|
{
|
|
public void OnAuthorization(AuthorizationContext filterContext)
|
|
{
|
|
AntiForgery.Validate();
|
|
}
|
|
}
|
|
public class UserApplication : HttpApplication
|
|
{
|
|
public void Application_Start()
|
|
{
|
|
GlobalFilters.Filters.Add(new AntiForgeryFilter());
|
|
}
|
|
}
|