Skip to content
  • Derek Prior's avatar
    4701a50b
    Deprecate controller level force_ssl · 4701a50b
    Derek Prior authored
    Today there are two common ways for Rails developers to force their
    applications to communicate over HTTPS:
    
    * `config.force_ssl` is a setting in environment configurations that
      enables the `ActionDispatch::SSL` middleware. With this middleware
      enabled, all HTTP communication to your application will be redirected
      to HTTPS. The middleware also takes care of other best practices by
      setting HSTS headers, upgrading all cookies to secure only, etc.
    * The `force_ssl` controller method redirects HTTP requests to certain
      controllers to HTTPS.
    
    As a consultant, I've seen many applications with misconfigured HTTPS
    setups due to developers adding `force_ssl` to `ApplicationController`
    and not enabling `config.force_ssl`. With this configuration, many
    application requests can be served over HTTP such as assets, requests
    that hit mounted engines, etc. In addition, because cookies are not
    upgraded to secure only in this configuration and HSTS headers are not
    set, it's possible for cookies that are meant to be secure to be sent
    over HTTP.
    
    The confusion between these two methods of forcing HTTPS is compounded
    by the fact that they share an identical name. This makes finding
    documentation on the "right" method confusing.
    
    HTTPS throughout is quickly becomming table stakes for all web sites.
    Sites are expected to operate over HTTPS for all communication,
    sensitive or otherwise. Let's encourage use of the broader-reaching
    `ActionDispatch::SSL` middleware and elminate this source of user
    confusion. If, for some reason, applications need to expose certain
    endpoints over HTTP they can do so by properly configuring
    `config.ssl_options`.
    4701a50b
    Deprecate controller level force_ssl
    Derek Prior authored
    Today there are two common ways for Rails developers to force their
    applications to communicate over HTTPS:
    
    * `config.force_ssl` is a setting in environment configurations that
      enables the `ActionDispatch::SSL` middleware. With this middleware
      enabled, all HTTP communication to your application will be redirected
      to HTTPS. The middleware also takes care of other best practices by
      setting HSTS headers, upgrading all cookies to secure only, etc.
    * The `force_ssl` controller method redirects HTTP requests to certain
      controllers to HTTPS.
    
    As a consultant, I've seen many applications with misconfigured HTTPS
    setups due to developers adding `force_ssl` to `ApplicationController`
    and not enabling `config.force_ssl`. With this configuration, many
    application requests can be served over HTTP such as assets, requests
    that hit mounted engines, etc. In addition, because cookies are not
    upgraded to secure only in this configuration and HSTS headers are not
    set, it's possible for cookies that are meant to be secure to be sent
    over HTTP.
    
    The confusion between these two methods of forcing HTTPS is compounded
    by the fact that they share an identical name. This makes finding
    documentation on the "right" method confusing.
    
    HTTPS throughout is quickly becomming table stakes for all web sites.
    Sites are expected to operate over HTTPS for all communication,
    sensitive or otherwise. Let's encourage use of the broader-reaching
    `ActionDispatch::SSL` middleware and elminate this source of user
    confusion. If, for some reason, applications need to expose certain
    endpoints over HTTP they can do so by properly configuring
    `config.ssl_options`.
Loading