Revoke active GitLab sessions for all users

If you have a self-hosted version of GitLab, you may need to revoke all active sessions for all users (for example, to force a password change when using an external authenticator like LDAP or OAuth2).

There isn’t a GUI action to do so, so we need to open the rails console gitlab-rails console -e production and issue a simple ruby command:

User.find_each do |user|
  ActiveSession.list(user).each do |session|
    ActiveSession.destroy_session(user, session.session_private_id)
  end
end