Comments (5)
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.
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.
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.
Interesting, thanks for the tip! @kbaum please ensure Rack::SslEnforcer
comes before ActionDispatch::Cookies
in your middleware stack.
from rack-ssl-enforcer.
@kbaum I'm closing here. Please reopen if needed.
from rack-ssl-enforcer.
Related Issues (20)
- Forcing HTTPS only on certain paths or methods might be a security problem
- Load balancer health check redirected; not making it to the app HOT 5
- Middleware use vs. insert_before HOT 1
- Does rack-ssl-enforcer have support for ssl client verification? HOT 1
- Increase the default HSTS max-age to 2 years
- Running code before redirect not working HOT 3
- Support for ruby 2.0 and Rails 4 HOT 2
- Release new version! <3 HOT 2
- Already encoded url parameters get encoded again when redirecting
- How to handle URI::InvalidURIError? HOT 7
- POST requests HOT 5
- Issue with IE only... strict true not working HOT 3
- Issue with Redirects HOT 3
- Infinite redirects behind AWS ELB HOT 5
- ERR_CONNECTION_REFUSED HOT 2
- use_redirect always forcing redirect, even for HTTPS HOT 2
- HSTS and secure cookies w/o redirect? HOT 2
- Does not set session cookie as secure HOT 6
- HSTS Implementation HOT 1
- Is there a changelog? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rack-ssl-enforcer.