2011-10-08 17:36:38 -04:00
|
|
|
# Be sure to restart your server when you modify this file.
|
|
|
|
|
2015-06-13 00:22:55 -04:00
|
|
|
require 'gitlab/current_settings'
|
2015-09-09 10:19:58 -04:00
|
|
|
|
2015-11-24 09:57:28 -05:00
|
|
|
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
|
2015-09-09 10:19:58 -04:00
|
|
|
begin
|
2017-08-31 05:47:03 -04:00
|
|
|
Settings.gitlab['session_expire_delay'] = Gitlab::CurrentSettings.current_application_settings.session_expire_delay || 10080
|
2015-09-09 10:19:58 -04:00
|
|
|
rescue
|
2015-11-24 06:11:31 -05:00
|
|
|
Settings.gitlab['session_expire_delay'] ||= 10080
|
2015-09-09 10:19:58 -04:00
|
|
|
end
|
2015-06-05 13:16:32 -04:00
|
|
|
|
2017-06-01 02:15:58 -04:00
|
|
|
cookie_key = if Rails.env.development?
|
|
|
|
"_gitlab_session_#{Digest::SHA256.hexdigest(Rails.root.to_s)}"
|
|
|
|
else
|
|
|
|
"_gitlab_session"
|
|
|
|
end
|
|
|
|
|
2015-10-22 09:38:11 -04:00
|
|
|
if Rails.env.test?
|
|
|
|
Gitlab::Application.config.session_store :cookie_store, key: "_gitlab_session"
|
|
|
|
else
|
2017-07-10 23:35:47 -04:00
|
|
|
sessions_config = Gitlab::Redis::SharedState.params
|
|
|
|
sessions_config[:namespace] = Gitlab::Redis::SharedState::SESSION_NAMESPACE
|
2016-05-30 17:13:42 -04:00
|
|
|
|
2015-10-22 09:38:11 -04:00
|
|
|
Gitlab::Application.config.session_store(
|
|
|
|
:redis_store, # Using the cookie_store would enable session replay attacks.
|
2017-07-10 23:35:47 -04:00
|
|
|
servers: sessions_config,
|
2017-06-01 02:15:58 -04:00
|
|
|
key: cookie_key,
|
2015-10-22 09:38:11 -04:00
|
|
|
secure: Gitlab.config.gitlab.https,
|
|
|
|
httponly: true,
|
2016-05-02 11:22:03 -04:00
|
|
|
expires_in: Settings.gitlab['session_expire_delay'] * 60,
|
2016-05-30 09:07:18 -04:00
|
|
|
path: Rails.application.config.relative_url_root.nil? ? '/' : Gitlab::Application.config.relative_url_root
|
2015-10-22 09:38:11 -04:00
|
|
|
)
|
|
|
|
end
|