Giter Site home page Giter Site logo

Comments (5)

ianneub avatar ianneub commented on June 3, 2024

I noticed that Rack::SslEnforcer will not set cookies to be secure on Rails 3.2 or Rails 4 (maybe others too). I'm guessing that functionality is not actually implemented for Rails > 3.1?

Here is my config:
config.middleware.use Rack::SslEnforcer, :hsts => true

I wanted to turn on secure cookies in rails, so I had to add this line as well:
config.force_ssl = true

from rack-ssl-enforcer.

rymai avatar rymai commented on June 3, 2024

Strange, cookies are flagged as secure by default unless you set the option :force_secure_cookies to false. See the implementation here: https://github.com/tobmatth/rack-ssl-enforcer/blob/master/lib/rack/ssl-enforcer.rb#L169-L180

@ianneub that's weird since rack-ssl-enforcer's implementation and the rack-ssl one are quite similar.

from rack-ssl-enforcer.

sslotnick avatar sslotnick commented on June 3, 2024

You have to be careful about where the middleware is inserted. The default instructions will insert it toward the bottom. I found that you need to insert it before ActionDispatch::Cookies in order for secure cookies to work properly.

Non-secure cookies:
config.middleware.insert_after ActionDispatch::Cookies, Rack::SslEnforcer

Secure cookies:
config.middleware.insert_before ActionDispatch::Cookies, Rack::SslEnforcer

from rack-ssl-enforcer.

rymai avatar rymai commented on June 3, 2024

Interesting, thanks for the tip! @kbaum please ensure Rack::SslEnforcer comes before ActionDispatch::Cookies in your middleware stack.

from rack-ssl-enforcer.

tobmatth avatar tobmatth commented on June 3, 2024

@kbaum I'm closing here. Please reopen if needed.

from rack-ssl-enforcer.

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.