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
e760a705
Commit
e760a705
authored
Feb 03, 2021
by
Imre Farkas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'document-activesession' into 'master'
Document ActiveSession See merge request gitlab-org/gitlab!48579
parents
c3016ebc
1c37d511
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
app/models/active_session.rb
app/models/active_session.rb
+24
-1
No files found.
app/models/active_session.rb
View file @
e760a705
# frozen_string_literal: true
# frozen_string_literal: true
# Backing store for GitLab session data.
#
# The raw session information is stored by the Rails session store
# (config/initializers/session_store.rb). These entries are accessible by the
# rack_key_name class method and consistute the base of the session data
# entries. All other entries in the session store can be traced back to these
# entries.
#
# After a user logs in (config/initializers/warden.rb) a further entry is made
# in Redis. This entry holds a record of the user's logged in session. These
# are accessible with the key_name(user_id, session_id) class method. These
# entries will expire. Lookups to these entries are lazilly cleaned on future
# user access.
#
# There is a reference to all sessions that belong to a specific user. A
# user may login through multiple browsers/devices and thus record multiple
# login sessions. These are accessible through the lookup_key_name(user_id)
# class method.
#
class
ActiveSession
class
ActiveSession
include
ActiveModel
::
Model
include
ActiveModel
::
Model
...
@@ -143,6 +162,10 @@ class ActiveSession
...
@@ -143,6 +162,10 @@ class ActiveSession
list
(
user
).
reject
(
&
:is_impersonated
)
list
(
user
).
reject
(
&
:is_impersonated
)
end
end
def
self
.
rack_key_name
(
session_id
)
"
#{
Gitlab
::
Redis
::
SharedState
::
SESSION_NAMESPACE
}
:
#{
session_id
}
"
end
def
self
.
key_name
(
user_id
,
session_id
=
'*'
)
def
self
.
key_name
(
user_id
,
session_id
=
'*'
)
"
#{
Gitlab
::
Redis
::
SharedState
::
USER_SESSIONS_NAMESPACE
}
:
#{
user_id
}
:
#{
session_id
}
"
"
#{
Gitlab
::
Redis
::
SharedState
::
USER_SESSIONS_NAMESPACE
}
:
#{
user_id
}
:
#{
session_id
}
"
end
end
...
@@ -197,7 +220,7 @@ class ActiveSession
...
@@ -197,7 +220,7 @@ class ActiveSession
end
end
def
self
.
rack_session_keys
(
rack_session_ids
)
def
self
.
rack_session_keys
(
rack_session_ids
)
rack_session_ids
.
map
{
|
session_id
|
"
#{
Gitlab
::
Redis
::
SharedState
::
SESSION_NAMESPACE
}
:
#{
session_id
}
"
}
rack_session_ids
.
map
{
|
session_id
|
rack_key_name
(
session_id
)
}
end
end
def
self
.
raw_active_session_entries
(
redis
,
session_ids
,
user_id
)
def
self
.
raw_active_session_entries
(
redis
,
session_ids
,
user_id
)
...
...
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