csrf

Managing Session Cookies with Firebase and Electron

不羁岁月 提交于 2021-01-27 13:24:29
问题 I am trying to set up session cookies in my Node server, which is the backend for an Electron app. I am trying to follow this guide. https://firebase.google.com/docs/auth/admin/manage-cookies The first thing I am confused about is where this function comes from in the "Sign In" section: const csrfToken = getCookie('csrfToken') Is 'getCookie' a function I am supposed to write myself? I am also not fully following the logic of the "create session cookie" snippet: const csrfToken = req.body

CSRF doesn't work on the first post attempt

老子叫甜甜 提交于 2021-01-27 06:27:28
问题 This is my first time implementing CSRF and first time posting on Stack. I've struggled through the CSRF config, but finally got something that almost works. If I open a bookmarked page in a fresh browser and submit a form, I'm seeing a 403 Invalid CSRF error: EBADCSRFTOKEN. In this case, the user auth is cookied so it does not challenge. I wonder if the session is expired? Subsequent posts work fine. Get requests are all fine. I'm stumped, time to put this challenge aside and ask for help as

Flask – multiple session cookies with the same name

青春壹個敷衍的年華 提交于 2021-01-21 04:23:43
问题 I have found a very strange problem in my Flask application. I discovered that in some circumstances multiple session cookies could be created with the same name. I attached a picture about it. It is not browser specific. It is strange itself, but the real problem comes when I try to validate a form with CSRF token. Unfortunately, Flask picks a wrong session cookie and the validation of the CSRF token cannot be successful. And even more strangely the problem persists even after multiple form

Flask – multiple session cookies with the same name

故事扮演 提交于 2021-01-21 04:22:04
问题 I have found a very strange problem in my Flask application. I discovered that in some circumstances multiple session cookies could be created with the same name. I attached a picture about it. It is not browser specific. It is strange itself, but the real problem comes when I try to validate a form with CSRF token. Unfortunately, Flask picks a wrong session cookie and the validation of the CSRF token cannot be successful. And even more strangely the problem persists even after multiple form

How do you solve the error KeyError: 'A secret key is required to use CSRF.' when using a wtform in flask application?

天大地大妈咪最大 提交于 2021-01-20 17:48:26
问题 I have been trying to build a web app using flask and wtforms and a firebase database, but I keep getting the error message "KeyError: 'A secret key is required to use CSRF.'" and I don't know how to solve it. here is my code: from flask import Flask, render_template, request from firebase import firebase from flask_wtf import FlaskForm from flask_wtf.csrf import CSRFProtect, CSRFError from wtforms import DateField, StringField, TextAreaField from wtforms.validators import DataRequired from

Why CSRF is not working in only POST route While working in the rest of other Post routes?

你说的曾经没有我的故事 提交于 2021-01-07 03:32:31
问题 I am getting the CSRF forbidden error . However CSRF is working fine in the rest of the application like post route of logout, signUp, Signin deleteing anything et c.. But when I perform the post action in only one route `/addProduct" I am getting the error Note that I am generating my CSRF token before routes declaration. I am attaching the main file code and the front end code of addProduct. Here is my main file code where I am generating token and including it in all routes app.use

Set httpOnly flag for CSRF token in Laravel

孤街浪徒 提交于 2020-12-29 09:57:33
问题 I'm building an application in Laravel 5.1 for a client. After I finished the application I got back an pentest report which tells me to add a HttpOnly flag. I added 'secure' => true and 'http_only' => true to app/config/session.php. The httpOnly flag is set for all sessions, except the XSRF-TOKEN session. How am I able to set this flag as well? 回答1: You are able to overwrite the method addCookieToResponse($request, $response) in App\Http\Middleware\VerifyCsrfToken /** * Add the CSRF token to

Set httpOnly flag for CSRF token in Laravel

China☆狼群 提交于 2020-12-29 09:57:19
问题 I'm building an application in Laravel 5.1 for a client. After I finished the application I got back an pentest report which tells me to add a HttpOnly flag. I added 'secure' => true and 'http_only' => true to app/config/session.php. The httpOnly flag is set for all sessions, except the XSRF-TOKEN session. How am I able to set this flag as well? 回答1: You are able to overwrite the method addCookieToResponse($request, $response) in App\Http\Middleware\VerifyCsrfToken /** * Add the CSRF token to

What does Cookie CsrfTokenRepository.withHttpOnlyFalse () do and when to use it?

瘦欲@ 提交于 2020-12-19 04:17:05
问题 I am trying to learn Spring Security right now and I have seen many different examples using this. I know what CSRF is and that Spring Security enables it by default. The thing that I am curious about to know is this kind of customization. .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .and() .authorizeRequests(request -> { request .antMatchers("/login").permitAll() .anyRequest() ....more code What kind of customization does .csrf().csrfTokenRepository

How are CSRF tokens stored on the server side ( by spring security or tomcat)

a 夏天 提交于 2020-12-15 01:42:12
问题 This question is not about how CSRF tokens works, but is rather about they are stored on the server side. In short, CSRF tokens are generated by server and injected in to the web page/form. When the form is submitted the csrf token is extracted by the server and compared to the one saved on the server. So far so good. From this earlier posting - CSRF token value when same page is opened in two tabs on same machine? Here's the excellent answer which explains that - The server will create a