csrf

CSRF token missing or incorrect. Django + AngularJS

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting CSRF token missing or incorrect error while doing a POST request to a remote django api from my localhost machine. My settings on AngularJS: .config(['$httpProvider', function($httpProvider){ $httpProvider.defaults.xsrfCookieName = 'csrftoken'; $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; }]); but im still getting the CSRF token missing or incorrect error. I check what headers are being sent and apparently angular is not sending HTTP_X_CSRFTOKEN . But I can see that the cookie csrftoken=something is sent. Does anyone

How can I use ring anti-forgery / CSRF token with latest version ring/compojure?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I copied some old code that was working in compojure 1.1.18 and other old libs, but using the latest versions I can't get it to work. Here's my minimal example code copied from the minimal example here to demonstrate that with latest ring and compojure libraries, I get an error when I send an http POST , even with the header set. lein ring server to start it, then do curl -X GET --cookie-jar cookies "http://localhost:3000/" which results in something like this: {"csrf-token":"7JnNbzx8BNG

Django CSRF cookie HttpOnly

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to set the django csrf cookie to be http-only? Alike to SESSION_COOKIE_HTTPONLY with session cookie, but for the csrf one? 回答1: A new setting, CSRF_COOKIE_HTTPONLY , is available in Django 1.6+. 回答2: For Django1.6+, check the accepted answer. For Django1.5 and prev, there is not setting option for this. You could override the process_response() method of django.middleware.csrf.CsrfViewMiddleware and using the customized one instead of CsrfViewMiddleware in MIDDLEWARE_CLASSES class Foo(CsrfViewMiddleware): def process_response

Angular 4 can't set CSRF-TOKEN in header

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a Spring boot RESTful service with Spring security configured like so: protected void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity.cors().and() /*.formLogin().loginPage("/auth") .permitAll().and() .authorizeRequests() .anyRequest() .authenticated() .and().httpBasic().and()*/ .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .and() .addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class); } & public class CsrfHeaderFilter extends OncePerRequestFilter { private static final String

Laravel 5.5 ajax call 419 (unknown status)

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I do an ajax call but I keep getting this error: 419 (unknown status) No idea what is causing this I saw on other posts it has to do something with csrf token but I have no form so I dont know how to fix this. my call: $('.company-selector li > a').click(function(e) { e.preventDefault(); var companyId = $(this).data("company-id"); $.ajax({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, url: '/fetch-company/' + companyId, dataType : 'json', type: 'POST', data: {}, contentType: false, processData: false, success

Is worrying about XSS,CSRF,sql injection, cookie stealing enough to cover web-security?

北城余情 提交于 2019-12-03 08:15:22
Web applications on uncompromised computers are vulnerable to XSS,CRSF,sql injection attacks and cookie stealing in unsecure wifi environments. To prevent those security issues there are the folowing remedies sql injection: a good datamapper(like linq-to-sql) does not have the risk of sql injection (am i naïeve to believe this?) CSRF: Every form-post is verified with the <%:Html.AntiForgeryToken() %> (this is a token in a asp.net mvc environment that is stored in a cookie and verified on the server) XSS: every form that is allowed to post html is converted, only bb code is allowed, the rest is

How do I generate CSRF tokens in Express?

人盡茶涼 提交于 2019-12-03 07:42:23
问题 newbie. I'm using ExpressJS/Node. Here's my config stuff: var express = require('express'), app = express.createServer(), jade=require('jade'); // Configuration app.configure(function(){ app.set('views', __dirname + '/views'); app.use(express.logger()); app.use(express.cookieParser()); app.use(express.session({ secret: "secretive secret" })); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(require('stylus').middleware({ src: __dirname

how to implement csrf protection for cross domain requests

社会主义新天地 提交于 2019-12-03 07:20:49
问题 I have two web apps, one for the Web UI in AngularJS and one for the REST webservices in Java. Both are deployed on separate domains. The applications uses cookie for authentication. Whenever user enters a valid username and password, server returns a http only cookie back containing the token and that cookie is passed across all requests. I have enabled CORS on both apps, thats why the session cookie is working properly. Now, I am trying to add CSRF protection for this. I was trying to use

Django CSRF Token without forms

 ̄綄美尐妖づ 提交于 2019-12-03 07:16:41
Sounds strange but what about the scenario posting contents with Javascript (for example AJAX) without using a form (could be possible to read several contents from the surface). Where should I place the csrf_token template tag? I already added the AJAX Fix: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax ...but I get the "CSRF verification failed. Request aborted." 404 Error. You must set a custom HTTP header, X-CSRFToken , in your AJAX request. See: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax If you've already followed that advice, it should be working. Use

Is it a good practice to store the csrf token in meta tag?

拈花ヽ惹草 提交于 2019-12-03 06:25:23
If I make a POST request without using form and want to prevent CSRF attack, what I can do is to set the csrf-token in meta tag and put it back to the header when the request is triggered. Is it a good practice? <meta name="csrf-token" content="xxx"> Put the token back via the header, using JQuery for example: $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); Yes this is good practice. If you are using ajax I think this is the cleanest solution. You could also put the token inside of the form (which is more convenient if submitting the whole form), but