##// END OF EJS Templates
Make the sudo timeout configurable (#19851)....
Jean-Philippe Lang -
r13971:b895f6434ddd
parent child
Show More
@@ -172,10 +172,11 default:
172 172
173 173 # Requires users to re-enter their password for sensitive actions (editing
174 174 # of account data, project memberships, application settings, user, group,
175 # role, auth source management and project deletion).
176 # Disabled by default.
175 # role, auth source management and project deletion). Disabled by default.
176 # Timeout is set in minutes.
177 177 #
178 178 #sudo_mode: true
179 #sudo_mode_timeout: 15
179 180
180 181 # Absolute path (e.g. /usr/bin/convert, c:/im/convert.exe) to
181 182 # the ImageMagick's `convert` binary. Used to generate attachment thumbnails.
@@ -4,10 +4,6 require 'rack/utils'
4 4 module Redmine
5 5 module SudoMode
6 6
7 # timespan after which sudo mode expires when unused.
8 MAX_INACTIVITY = 15.minutes
9
10
11 7 class SudoRequired < StandardError
12 8 end
13 9
@@ -132,7 +128,7 module Redmine
132 128 end
133 129
134 130 def sudo_timestamp_valid?
135 session[:sudo_timestamp].to_i > MAX_INACTIVITY.ago.to_i
131 session[:sudo_timestamp].to_i > SudoMode.timeout.ago.to_i
136 132 end
137 133
138 134 def update_sudo_timestamp!(new_value = Time.now.to_i)
@@ -218,6 +214,10 module Redmine
218 214 def self.enabled?
219 215 Redmine::Configuration['sudo_mode'] && !RequestStore.store[:sudo_mode_disabled]
220 216 end
217
218 # Timespan after which sudo mode expires when unused.
219 def self.timeout
220 Redmine::Configuration['sudo_mode_timeout'].to_i.minutes
221 end
221 222 end
222 223 end
223
General Comments 0
You need to be logged in to leave comments. Login now