Commit 1d080f57 authored by themaze75's avatar themaze75 Committed by Eric Maziade

session_expire_seconds => session_expire_delay

delay is in seconds
more legible code in session_store
Added `GitLab restart required` help block to session_expire_delay
parent 84a414fe
......@@ -40,7 +40,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:home_page_url,
:after_sign_out_path,
:max_attachment_size,
:session_expire_seconds,
:session_expire_delay,
:default_project_visibility,
:default_snippet_visibility,
:restricted_signup_domains_raw,
......
......@@ -15,7 +15,7 @@
# twitter_sharing_enabled :boolean default(TRUE)
# restricted_visibility_levels :text
# max_attachment_size :integer default(10), not null
# session_expire_seconds :integer default(604800), not null
# session_expire_delay :integer default(10080), not null
# default_project_visibility :integer
# default_snippet_visibility :integer
# restricted_signup_domains :text
......@@ -27,6 +27,10 @@ class ApplicationSetting < ActiveRecord::Base
serialize :restricted_visibility_levels
serialize :restricted_signup_domains, Array
attr_accessor :restricted_signup_domains_raw
validates :session_expire_delay,
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :home_page_url,
allow_blank: true,
......@@ -62,7 +66,7 @@ class ApplicationSetting < ActiveRecord::Base
sign_in_text: Settings.extra['sign_in_text'],
restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
max_attachment_size: Settings.gitlab['max_attachment_size'],
session_expire_seconds: Settings.gitlab['session_expire_seconds'],
session_expire_delay: Settings.gitlab['session_expire_delay'],
default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
restricted_signup_domains: Settings.gitlab['restricted_signup_domains']
......
......@@ -84,9 +84,10 @@
.col-sm-10
= f.number_field :max_attachment_size, class: 'form-control'
.form-group
= f.label :session_expire_seconds, 'Session duration (seconds)', class: 'control-label col-sm-2'
= f.label :session_expire_delay, 'Session duration (minutes)', class: 'control-label col-sm-2'
.col-sm-10
= f.number_field :session_expire_seconds, class: 'form-control'
= f.number_field :session_expire_delay, class: 'form-control'
%span.help-block#session_expire_delay_help_block GitLab restart is required to apply changes
.form-group
= f.label :restricted_signup_domains, 'Restricted domains for sign-ups', class: 'control-label col-sm-2'
.col-sm-10
......
......@@ -128,7 +128,7 @@ Settings.gitlab['issue_closing_pattern'] = '((?:[Cc]los(?:e[sd]?|ing)|[Ff]ix(?:e
Settings.gitlab['default_projects_features'] ||= {}
Settings.gitlab['webhook_timeout'] ||= 10
Settings.gitlab['max_attachment_size'] ||= 10
Settings.gitlab['session_expire_seconds'] ||= 604800
Settings.gitlab['session_expire_delay'] ||= 10080
Settings.gitlab.default_projects_features['issues'] = true if Settings.gitlab.default_projects_features['issues'].nil?
Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.gitlab.default_projects_features['merge_requests'].nil?
Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil?
......
# Be sure to restart your server when you modify this file.
if ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings')
Settings.gitlab['session_expire_delay'] = ApplicationSetting.current.session_expire_delay
end
Gitlab::Application.config.session_store(
:redis_store, # Using the cookie_store would enable session replay attacks.
servers: Gitlab::Application.config.cache_store[1].merge(namespace: 'session:gitlab'), # re-use the Redis config from the Rails cache store
key: '_gitlab_session',
secure: Gitlab.config.gitlab.https,
httponly: true,
expire_after: ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?('application_settings') ? ApplicationSetting.current.session_expire_seconds : Settings.gitlab['session_expire_seconds'],
expire_after: Settings.gitlab['session_expire_delay'] * 60,
path: (Rails.application.config.relative_url_root.nil?) ? '/' : Rails.application.config.relative_url_root
)
)
\ No newline at end of file
class AddSessionExpireSecondsForApplicationSettings < ActiveRecord::Migration
def change
add_column :application_settings, :session_expire_seconds, :integer, default: 604800, null: false
end
end
\ No newline at end of file
class AddSessionExpireDelayForApplicationSettings < ActiveRecord::Migration
def change
add_column :application_settings, :session_expire_delay, :integer, default: 10080, null: false
end
end
\ No newline at end of file
......@@ -35,7 +35,7 @@ ActiveRecord::Schema.define(version: 20150604202921) do
t.text "restricted_signup_domains"
t.boolean "user_oauth_applications", default: true
t.string "after_sign_out_path"
t.integer "session_expire_seconds", default: 604800, null: false
t.integer "session_expire_delay", default: 10080, null: false
end
create_table "broadcast_messages", force: true do |t|
......
......@@ -22,7 +22,7 @@ module Gitlab
sign_in_text: Settings.extra['sign_in_text'],
restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
max_attachment_size: Settings.gitlab['max_attachment_size'],
session_expire_seconds: Settings.gitlab['session_expire_seconds']
session_expire_delay: Settings.gitlab['session_expire_delay']
)
end
end
......
......@@ -15,7 +15,7 @@
# twitter_sharing_enabled :boolean default(TRUE)
# restricted_visibility_levels :text
# max_attachment_size :integer default(10), not null
# session_expire_seconds :integer default(604800), not null
# session_expire_delay :integer default(10080), not null
# default_project_visibility :integer
# default_snippet_visibility :integer
# restricted_signup_domains :text
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment