csrf

ASP.NET MVC - ValidateAntiForgeryToken expiring

ぐ巨炮叔叔 提交于 2019-12-03 06:22:31
In a web page we provide a hyperlink (GET) that the User may click on to authenticate: @Html.ActionLink("Please Login", "MyMethod", "MyController") This maps to the following controller method which returns a View: [RequireHttps] public ActionResult MyMethod() { return this.View(new MyModel()); } This View contains the Form in which the User supplies their credentials; the Form contains the required AntiForgeryToken. When the User submits the form, the following Controller method is called: [HttpPost] [RequireHttps] [ValidateAntiForgeryToken] public ActionResult MyMethod(MyModel model) { // my

Cross domain ajax POST in chrome

孤人 提交于 2019-12-03 06:18:52
问题 There are several topics about the problem with cross-domain AJAX. I've been looking at these and the conclusion seems to be this: Apart from using somthing like JSONP, or a proxy sollution, you should not be able to do a basic jquery $.post() to another domain My test code looks something like this (running on "http://myTestdomain.tld/path/file.html") var myData = {datum1 : "datum", datum2: "datum"} $.post("http://External-Ip:port", myData,function(return){alert(return);}); When I tried this

GWT RPC - Does it do enough to protect against CSRF?

独自空忆成欢 提交于 2019-12-03 06:17:59
UPDATE : GWT 2.3 introduces a better mechanism to fight XSRF attacks. See http://code.google.com/webtoolkit/doc/latest/DevGuideSecurityRpcXsrf.html GWT's RPC mechanism does the following things on every HTTP Request - Sets two custom request headers - X-GWT-Permutation and X-GWT-Module-Base Sets the content-type as text/x-gwt-rpc; charset=utf-8 The HTTP request is always a POST, and on server side GET methods throw an exception (method not supported). Also, if these headers are not set or have the wrong value, the server fails processing with an exception "possibly CSRF?" or something to that

CSRF token expires during login

耗尽温柔 提交于 2019-12-03 06:06:34
问题 I'm working on Spring web application and I need to avoid problem with expire csrf token on login page, because if user is waiting too long and try to login only one way to resolve problem with csrf is to reload page and try to login again. But it's not user friendly and I want to avoid this situation. First question: Is it possible in general(by spring security 3.2.4)? Without disable csrf. I tried to use security="none" for login page and spring seciruty "login_check", but it's not working,

Is is possible to make a cross domain POST ajax request of application/json?

怎甘沉沦 提交于 2019-12-03 05:09:19
I am testing some csrf stuff, and I am wondering if it is possible to POST a cross domain ajax request with Content-Type: application/json Every time I try to do this with jQuery: $.ajax({ type: "post", url: "http://someotherdomain.com/endpoint", contentType: "application/json; charset=UTF-8", data: {"a": "1"}, dataType: "json", crossDomain: true, success: function(data){ alert(data); }, failure: function(data){ alert(data); } }); I always send HTTP OPTIONS requests instead of HTTP POSTs . Note- that I don't care about receiving data back, a one way post is all I need. Note- that the content

FOSUserBundle & REST Api Call: How to use custom FormType?

↘锁芯ラ 提交于 2019-12-03 05:04:16
I am using FOSUserBundle on my Symfony2 Website. Now I am working on an API to allow registration over a REST api call. I have overridden the RegistrationController of FOSUserBundle: ApiRegistrationController.php: /** * @Route("/user/", defaults = { "_format" = "json" }, requirements = { "_method" = "POST" }) * */ public function registerAction(Request $request) { [...] $form = $formFactory->createForm(new ApiRegistrationFormType(), $user); [...] } ApiRegistrationFormType.php: /** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface

How specifically does Laravel build and check a CSRF token?

坚强是说给别人听的谎言 提交于 2019-12-03 04:50:01
I'm using Laravel's CSRF protection on my public site. However since Laravel uses a session to maintain this, I'm worried that a user might walk away from their computer and return to a page they have previously left open, only to find ajax requests don't work. The ajax requests don't work because the session has timed out (and the token no longer validates?). If these users were "logged in" users, then I could simply redirect them back to the login page. Since they are public users, then the user is forced to refresh the page to get it back working (awkward). Or am I wrong about this? Would

How to csrf_token protection in jinja2 template engine?

笑着哭i 提交于 2019-12-03 04:27:32
In Django template I used: <form action="/user" method="post">{% csrf_token %} {{ form.as_p|safe }} <input type="submit" value="Submit" /> </form> But error when I change to jinja2 template engine : Encountered unknown tag 'csrf_token' My question: csrf_token protection in jinja2 is required? If required, how to do this? Thanks in advance! It seems Jinja2 works differently: Use <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}"> where in Django templates you use {% csrf_token %} source : http://exyr.org/2010/Jinja-in-Django/ I know this is an old question, but I wanted to

Does a proper CORS setup prevent XSRF?

三世轮回 提交于 2019-12-03 04:12:03
问题 If CORS is properly setup on a server to only allow a certain origins to access the server, is this enough to prevent XSRF attacks? 回答1: To be more specific, it is easy to make the mistake of thinking that if evil.com cannot make a request to good.com due to CORS then CSRF is prevented. There are two problems being overlooked, however: CORS is respected by the browsers only. That means Google Chrome will obey CORS and not let evil.com make a request to good.com. However, imagine someone

Securing Single-page-application from CSRF and XSS using CSP + localStorage

独自空忆成欢 提交于 2019-12-03 03:47:37
I have a single page application, having sensitive content, and needs to be secured. This question is specific with securing against XSS and CSRF attacks. Explanation: It has been suggested many places, for example here to use cookies on top of localStorage while storing the auth-token. A very nice explanation is also provided in answer of another question here . Based on these answers, for secured contents, it is suggested to use cookies with ‘httpOnly’ and ‘secure’ options to avoid XSS; and implement CSRF protection by ourselves (something like anti-forgery-token in asp.net ) (Note that I am