csrf

Why should I put a CSRF token in a JWT token?

余生长醉 提交于 2019-12-03 03:46:40
I want to bring a doubt about JWT tokens and CSRF from the Stormpath post that explain the advantages and disadvantages of storing the JWT either in localStorage or cookies. [...] if you are reading values out of a cookie using JS, that means you can't set the Httponly flag on the cookie, so now any JS on your site can read it, thus making it the exact same security-level as storing something in localStorage. I'm trying to understand why they recommend adding the xsrfToken to the JWT. Doesn't storing your JWT in the cookie and then extracting it out and placing the JWT in the HTTP header and

Override the protect_from_forgery strategy in a controller

放肆的年华 提交于 2019-12-03 03:40:36
I want to build a rails app with two different protect_from_forgery strategies: one for the web application, and one for the API. In my application controller I have this line of code: protect_from_forgery with: :exception in order to prevent CSRF attacks, it works just fine. In my API namespace, I created an api_controller that inherits from my application controller, and that is the parent class of all the other controllers in the API namespace, and I changed the code above with: protect_from_forgery with: :null_session . Sadly, I have an error when trying to make POST request: "Can't verify

CSRF and RESTful API (symfony2, php)

喜你入骨 提交于 2019-12-03 03:10:15
I'm developing RESTful API using php/symfony2. Symfony2 comes with CSRF protection out of the box and it works fine when using normal form data (it passes CSRF token to the form and when posted back it expects the same token which is embeded in the form). Nonetheless this solution is not fit for purpose if you develop RESTful API, where my communication between backend<->frontend is purely JSON based. Because of that I disabled CSRF. I'm aware not having CSRF token is not safe, so I'm wondering what's the most optimal way to have CSRF with RESTful API. One idea in mind is to have specific URL

HTTP Status 403 - Invalid CSRF Token &#039;null&#039; was found on the request parameter

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to issue a HTTP.Post (Android App) to my restful service, to register a new user! The problem is, when I try to issue a request to a register endpoint ( without security ), Spring keeps blocking me! My Project Dependencies <properties> <java-version>1.6</java-version> <org.springframework-version>4.1.7.RELEASE</org.springframework-version> <org.aspectj-version>1.6.10</org.aspectj-version> <org.slf4j-version>1.6.6</org.slf4j-version> <jackson.version>1.9.10</jackson.version> <spring.security.version>4.0.2.RELEASE</spring.security

codeigniter CSRF error: “The action you have requested is not allowed.”

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i enabled the csrf_protection option in the codeigniter's config file, and used form_open() function to creat my forms. but when i submit the form, this error occurs: The action you have requested is not allowed. i have done the answers like this topic (taht is most related to my question): question but they didn't work and The problem still remains. config.php

Django的中间件

你说的曾经没有我的故事 提交于 2019-12-03 02:36:32
Django的中间件 什么是中间件 中间件是一个用来处理Django的请求和响应的框架级别的钩子。它 是一个轻量、低级别的插件系统,用于在全局范围内改变Django的输入和输出。 Django默认使用的中间件 在Django项目的setting.py文件中 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] 中间件是按照配置文件中的顺序来执行地 自定义中间件 在项目的任意位置新建一个文件夹,文件夹中新建任意一个.py文件,在文件中添加如下内容: from django

JQuery: post FormData AND csrf token together

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Is the data:.. line below correct? I want to post the form data AND csrf token to a Django view function. $('#file-upload').on('change', function () { var currentpath = window.location.pathname; var formData = new FormData($('form')[0]); $.ajax({ url: currentpath, //server script to process data type: 'POST', data: {formData, 'csrfmiddlewaretoken': '{{ csrf_token }}'}, cache: false, contentType: false, processData: false }); }); 回答1: You have to add your parameters to the FormData object (using append ) and as always pass the

Play 2.5 disable csrf protection for some requests

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm writing my app using play framework v. 2.5.3 and use CSRF protection as it is described in official documentation. public class Filters implements HttpFilters { @Inject CSRFFilter csrfFilter ; @Override public EssentialFilter [] filters () { return new EssentialFilter []{ csrfFilter . asJava ()}; }} Of course, it works, as long as all of requests need to be filtered, but some of them should be bypassed. How can filters be configured to bypass requests to some specified route? Thanks for your help! 回答1: You can decorate

Django - CSRF token missing or incorrect

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just updated my django to 1.4. But I am getting the following error when I try to submit my login form: Forbidden (403) CSRF verification failed. Request aborted. Reason given for failure: CSRF token missing or incorrect. In my settings.py (MIDDLEWARE_CLASSES) I had to remove the following line because its now deprecated: 'django.middleware.csrf.CsrfResponseMiddleware', And than I started to to get this error. Some necessary information: Urls.py url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'registration/login.html'

Could not verify the provided CSRF token because your session was not found in spring security

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using spring security along with java config @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/api/*").hasRole("ADMIN") .and() .addFilterAfter(new CsrfTokenResponseHeaderBindingFilter(), CsrfFilter.class) .exceptionHandling() .authenticationEntryPoint(restAuthenticationEntryPoint) .and() .formLogin() .successHandler(authenticationSuccessHandler) .failureHandler(new SimpleUrlAuthenticationFailureHandler()); I am using PostMan for testing my REST services. I get 'csrf token'