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