2021-02-03 16:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2021-04-26 08:09:44 -04:00
|
|
|
rescue StandardError
|
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)}"
|
2021-09-14 23:11:01 -04:00
|
|
|
elsif ::Gitlab.ee? && ::Gitlab::Geo.connected? && ::Gitlab::Geo.secondary?
|
|
|
|
"_gitlab_session_geo_#{Digest::SHA256.hexdigest(GeoNode.current_node_name)}"
|
2017-06-01 02:15:58 -04:00
|
|
|
else
|
|
|
|
"_gitlab_session"
|
|
|
|
end
|
|
|
|
|
2022-01-13 01:14:35 -05:00
|
|
|
store = Gitlab::Redis::Sessions.store(namespace: Gitlab::Redis::Sessions::SESSION_NAMESPACE)
|
2016-05-30 17:13:42 -04:00
|
|
|
|
2021-11-24 13:14:31 -05:00
|
|
|
Gitlab::Application.config.session_store(
|
|
|
|
:redis_store, # Using the cookie_store would enable session replay attacks.
|
|
|
|
redis_store: store,
|
|
|
|
key: cookie_key,
|
|
|
|
secure: Gitlab.config.gitlab.https,
|
|
|
|
httponly: true,
|
|
|
|
expires_in: Settings.gitlab['session_expire_delay'] * 60,
|
|
|
|
path: Rails.application.config.relative_url_root.presence || '/'
|
|
|
|
)
|