1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Make the sudo timeout configurable (#19851).

git-svn-id: http://svn.redmine.org/redmine/trunk@14353 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-06-19 21:17:52 +00:00
parent 8cf83d494c
commit b895f6434d
2 changed files with 9 additions and 8 deletions

View File

@ -172,10 +172,11 @@ default:
# Requires users to re-enter their password for sensitive actions (editing # Requires users to re-enter their password for sensitive actions (editing
# of account data, project memberships, application settings, user, group, # of account data, project memberships, application settings, user, group,
# role, auth source management and project deletion). # role, auth source management and project deletion). Disabled by default.
# Disabled by default. # Timeout is set in minutes.
# #
#sudo_mode: true #sudo_mode: true
#sudo_mode_timeout: 15
# Absolute path (e.g. /usr/bin/convert, c:/im/convert.exe) to # Absolute path (e.g. /usr/bin/convert, c:/im/convert.exe) to
# the ImageMagick's `convert` binary. Used to generate attachment thumbnails. # the ImageMagick's `convert` binary. Used to generate attachment thumbnails.

View File

@ -4,10 +4,6 @@ require 'rack/utils'
module Redmine module Redmine
module SudoMode module SudoMode
# timespan after which sudo mode expires when unused.
MAX_INACTIVITY = 15.minutes
class SudoRequired < StandardError class SudoRequired < StandardError
end end
@ -132,7 +128,7 @@ module Redmine
end end
def sudo_timestamp_valid? def sudo_timestamp_valid?
session[:sudo_timestamp].to_i > MAX_INACTIVITY.ago.to_i session[:sudo_timestamp].to_i > SudoMode.timeout.ago.to_i
end end
def update_sudo_timestamp!(new_value = Time.now.to_i) def update_sudo_timestamp!(new_value = Time.now.to_i)
@ -218,6 +214,10 @@ module Redmine
def self.enabled? def self.enabled?
Redmine::Configuration['sudo_mode'] && !RequestStore.store[:sudo_mode_disabled] Redmine::Configuration['sudo_mode'] && !RequestStore.store[:sudo_mode_disabled]
end end
end
end
# Timespan after which sudo mode expires when unused.
def self.timeout
Redmine::Configuration['sudo_mode_timeout'].to_i.minutes
end
end
end