Giter Site home page Giter Site logo

Having issues with cuba safe about cuba HOT 9 CLOSED

soveran avatar soveran commented on May 22, 2024
Having issues with cuba safe

from cuba.

Comments (9)

soveran avatar soveran commented on May 22, 2024

Are you using sessions?

from cuba.

Bezbo avatar Bezbo commented on May 22, 2024

yes, i've got

Cuba.use Rack::Session::Cookie, :secret => "_this_must_be_secret"
Cuba.plugin Cuba::Safe
Cuba.plugin Cuba::Render

in app.rb

from cuba.

soveran avatar soveran commented on May 22, 2024

I don't know if I'm replicating your use case correctly. This is what I tried: I created a form where I insert the csrf.form_tag and I submit a POST request to /idea. Then I render a template that tells me whether or not the request was safe, and it works. I can share the code if you prefer, but as I'm guessing I'm not reproducing exactly what you are doing, maybe you want to paste more code to show me why it fails?

from cuba.

Bezbo avatar Bezbo commented on May 22, 2024

I am sending the csrf token with json, so the client gets it with a request to /idea GET, and then it posts some data with the token, that he got.

from cuba.

soveran avatar soveran commented on May 22, 2024

Can you show me how you post the token?

from cuba.

Bezbo avatar Bezbo commented on May 22, 2024

I tried sending it in the test like that post "idea", "csrf_token" => csrf_token
Also I tried sending it with the header, (this did not work).
And now I decided just to write a js client, to see if the session works.
So I did it. And if I send the token using js inside a json and then compare it with session[:csrf_token] - they are equal, but still, if I send it inside header - I get that csrf.safe? is false

from cuba.

soveran avatar soveran commented on May 22, 2024

Hey @Bezbo, do you have some code to reproduce this? It's fine if you don't, I have some time and I can take a look at it later.

from cuba.

slowernet avatar slowernet commented on May 22, 2024

@Bezbo You're not by any chance hitting the POST endpoint without the right Content-type header (eg. application/x-www-form-urlencoded) to trigger parameter parsing, are you? I ask because I was just bitten by this experimenting with the bare metal fetch API.

from cuba.

soveran avatar soveran commented on May 22, 2024

Closing this issue for now because it's working for me. If you run into this issue, please let me know so we can investigate further.

from cuba.

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.