session_store.rb 1.03 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2
# Be sure to restart your server when you modify this file.

3 4
require 'gitlab/current_settings'
include Gitlab::CurrentSettings
5

6
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
7
begin
8
  Settings.gitlab['session_expire_delay'] = current_application_settings.session_expire_delay || 10080
9
rescue
10
  Settings.gitlab['session_expire_delay'] ||= 10080
11
end
12

13 14 15
if Rails.env.test?
  Gitlab::Application.config.session_store :cookie_store, key: "_gitlab_session"
else
16
  redis_config = Gitlab::Redis.redis_store_options
17
  redis_config[:namespace] = Gitlab::Redis::SESSION_NAMESPACE
18
  
19 20
  Gitlab::Application.config.session_store(
    :redis_store, # Using the cookie_store would enable session replay attacks.
21
    servers: redis_config,
22 23 24 25
    key: '_gitlab_session',
    secure: Gitlab.config.gitlab.https,
    httponly: true,
    expire_after: Settings.gitlab['session_expire_delay'] * 60,
Valery Sizov's avatar
Valery Sizov committed
26
    path: (Rails.application.config.relative_url_root.nil?) ? '/' : Gitlab::Application.config.relative_url_root
27 28
  )
end