docbrown/config/initializers/session_store.rb
Ben Halpern a4a14a5377
[deploy] Make force_ssl an environment variable to make sure new communities can get proper ssl config. (#7090)
* Add conditional for redirect

* Force ssl

* Redis secure

* More push

* Add FORCE_SSL_IN_RAILS env var
2020-04-08 14:23:50 -04:00

17 lines
1 KiB
Ruby

# Be sure to restart your server when you modify this file.
# we want a default in case the expiration is not set or set to 0
# because 0 is an invalid value
app_config_expires_after = ApplicationConfig["SESSION_EXPIRY_SECONDS"].to_i
expires_after = app_config_expires_after.positive? ? app_config_expires_after : 2.weeks.to_i
# see <https://github.com/redis-store/redis-rails#session-storage> for configuration options,
# httponly has been added in <https://github.com/redis-store/redis-actionpack/pull/17>
servers = ApplicationConfig["REDIS_SESSIONS_URL"] || ApplicationConfig["REDIS_URL"]
Rails.application.config.session_store :redis_store,
key: ApplicationConfig["SESSION_KEY"],
servers: servers,
expire_after: expires_after,
signed: true,
secure: ApplicationConfig["FORCE_SSL_IN_RAILS"] == "true",
httponly: true