Active sessions are not logged out after impersonating a user

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

After impersonating a user as an admin user, the admin user will have another active session that is logged into the account.

Steps to reproduce

  • Login as admin to a GitLab instance.
  • Check https://<gitlab_instance_url>/-/profile/active_sessions for number of actives sessions.
  • Impersonate any user.
  • Stop impersonating the user.
  • Check https://<gitlab_instance_url>/-/profile/active_sessions again as the admin user. The number of active sessions has increased by one.

What is the current bug behavior?

An active session is created and not logged out after impersonating a user.

What is the expected correct behavior?

  • The active session is either not created as part of impersonating, or is logged out after impersonating has been stopped.

Relevant logs and/or screenshots

Action sessions before impersonating image
Action sessions after impersonating image

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
# sudo gitlab-rake gitlab:env:info

System information
System:		Ubuntu 22.04
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.7.7p221
Gem Version:	3.1.6
Bundler Version:2.3.15
Rake Version:	13.0.6
Redis Version:	6.2.8
Sidekiq Version:6.5.7
Go Version:	unknown

GitLab information
Version:	15.9.3-ee
Revision:	d3356768b48
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.8
URL:		https://1.k.git2.cyou
HTTP Clone URL:	https://1.k.git2.cyou/some-group/some-project.git
SSH Clone URL:	git@1.k.git2.cyou:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers:

GitLab Shell
Version:	14.17.0
Repository storages:
- default: 	unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

Results of GitLab application Check

Expand for output related to the GitLab application check
# sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.17.0 ? ... OK (14.17.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither initscript nor systemd units) Projects have namespace: ... 2/1 ... yes 12/2 ... yes 12/3 ... yes 13/4 ... yes 13/5 ... yes 13/6 ... yes 14/7 ... yes 14/8 ... yes 15/9 ... yes 15/10 ... yes 15/11 ... yes 26/12 ... yes 1/13 ... yes 26/16 ... yes 26/18 ... yes 26/19 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.7) Git user has default SSH configuration? ... yes Active users: ... 11 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Edited by 🤖 GitLab Bot 🤖