Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/active_session.rb')
-rw-r--r--app/models/active_session.rb25
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)