Giter Club home page Giter Club logo

Comments (6)

shaunwarman avatar shaunwarman commented on August 19, 2024

You can drop a hidden element on the page with your created csrf similar to this kraken example

Be sure that you have a session to hold onto the secret for validation purposes.

Flow:

  • Incoming non-safe http verb with csrf header
  • parse request
  • lusca middleware finds _csrf and uses secret from session to validate _csrf

from lusca.

mrazvan21 avatar mrazvan21 commented on August 19, 2024

@shaunwarman I use csrf in cookie :) not in html :)
with param angular true in lusca settings

from lusca.

shaunwarman avatar shaunwarman commented on August 19, 2024

Ah, ok perfect! What are you trying to change?

from lusca.

mrazvan21 avatar mrazvan21 commented on August 19, 2024

I use node.js in apache (proxy).
I want to set XSRF-TOKEN with flag security true (obvious use https :D)
Session is set with security true but csrf can't set directly from lusca only If I overwrite res.cookie because from lusca when set xsrf, cookie is not set with options.secure = true;

You can see here https://github.com/krakenjs/lusca/blob/master/lib/csrf.js at line 49 (res.cookie(cookie, token);)

I'm forwarding ssl details from apache at node, node knows that site is on https (ssl is set from apache conf)). I set in express-session at cookie section secure= true;

I managed to set csrf with security=true only if I overwritten res.cookie (when options.secure true is not set I set automatically to true if https is active) but I don't like this...

I don't understand what I omitted..

from lusca.

stgogm avatar stgogm commented on August 19, 2024

I'm facing the same issue and as I see, there's no way to set the cookie as secure or HTTP only but to overwrite it.

This is because the CSRF configuration doesn't accept options for the cookie.

https://expressjs.com/en/api.html#res.cookie

from lusca.

stgogm avatar stgogm commented on August 19, 2024

Opened a pull request with a possible solution: #104

from lusca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.