Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
36cfd946
Commit
36cfd946
authored
Mar 19, 2020
by
Diego Louzán
Committed by
Imre Farkas
Mar 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable lookup of other ActiveSessions to determine admin mode status
parent
37e4fc93
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
14 deletions
+10
-14
changelogs/unreleased/refactor-admin-mode-single-session.yml
changelogs/unreleased/refactor-admin-mode-single-session.yml
+5
-0
lib/gitlab/auth/current_user_mode.rb
lib/gitlab/auth/current_user_mode.rb
+3
-12
spec/lib/gitlab/auth/current_user_mode_spec.rb
spec/lib/gitlab/auth/current_user_mode_spec.rb
+2
-2
No files found.
changelogs/unreleased/refactor-admin-mode-single-session.yml
0 → 100644
View file @
36cfd946
---
title
:
Disable lookup of other ActiveSessions to determine admin mode status
merge_request
:
27318
author
:
Diego Louzán
type
:
changed
lib/gitlab/auth/current_user_mode.rb
View file @
36cfd946
...
...
@@ -77,7 +77,7 @@ module Gitlab
return
false
unless
user
Gitlab
::
SafeRequestStore
.
fetch
(
admin_mode_rs_key
)
do
user
.
admin?
&&
any_
session_with_admin_mode?
user
.
admin?
&&
session_with_admin_mode?
end
end
...
...
@@ -136,19 +136,10 @@ module Gitlab
@current_session
||=
Gitlab
::
NamespacedSessionStore
.
new
(
SESSION_STORE_KEY
)
end
def
any_
session_with_admin_mode?
def
session_with_admin_mode?
return
true
if
bypass_session?
return
true
if
current_session_data
.
initiated?
&&
current_session_data
[
ADMIN_MODE_START_TIME_KEY
].
to_i
>
MAX_ADMIN_MODE_TIME
.
ago
.
to_i
all_sessions
.
any?
do
|
session
|
session
[
ADMIN_MODE_START_TIME_KEY
].
to_i
>
MAX_ADMIN_MODE_TIME
.
ago
.
to_i
end
end
def
all_sessions
@all_sessions
||=
ActiveSession
.
list_sessions
(
user
).
lazy
.
map
do
|
session
|
Gitlab
::
NamespacedSessionStore
.
new
(
SESSION_STORE_KEY
,
session
.
with_indifferent_access
)
end
current_session_data
.
initiated?
&&
current_session_data
[
ADMIN_MODE_START_TIME_KEY
].
to_i
>
MAX_ADMIN_MODE_TIME
.
ago
.
to_i
end
def
admin_mode_requested_in_grace_period?
...
...
spec/lib/gitlab/auth/current_user_mode_spec.rb
View file @
36cfd946
...
...
@@ -151,13 +151,13 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode, :request_store
allow
(
ActiveSession
).
to
receive
(
:list_sessions
).
with
(
user
).
and_return
([
session
,
another_session
])
end
it
'can be enabled in one and seen in the other'
do
it
'can
not
be enabled in one and seen in the other'
do
Gitlab
::
Session
.
with_session
(
another_session
)
do
another_subject
.
request_admin_mode!
another_subject
.
enable_admin_mode!
(
password:
user
.
password
)
end
expect
(
subject
.
admin_mode?
).
to
be
(
tru
e
)
expect
(
subject
.
admin_mode?
).
to
be
(
fals
e
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment