diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/active_session.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/active_session.rb')
-rw-r--r-- | app/models/active_session.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/app/models/active_session.rb b/app/models/active_session.rb index dded0eb1dc3..823685f78f4 100644 --- a/app/models/active_session.rb +++ b/app/models/active_session.rb @@ -1,5 +1,24 @@ # 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 include ActiveModel::Model @@ -143,6 +162,10 @@ class ActiveSession list(user).reject(&:is_impersonated) end + def self.rack_key_name(session_id) + "#{Gitlab::Redis::SharedState::SESSION_NAMESPACE}:#{session_id}" + end + def self.key_name(user_id, session_id = '*') "#{Gitlab::Redis::SharedState::USER_SESSIONS_NAMESPACE}:#{user_id}:#{session_id}" end @@ -197,7 +220,7 @@ class ActiveSession end 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 def self.raw_active_session_entries(redis, session_ids, user_id) |