2 # https://about.gitlab.com/2017/03/20/gitlab-8-dot-17-dot-4-security-release/
4 # lib/tasks/reset_token.rake
5 require_relative '../../app/models/concerns/token_authenticatable.rb'
10 desc "Reset all GitLab user auth tokens"
11 task reset_all: :environment do
12 reset_all_users_token(:reset_authentication_token!)
15 desc "Reset all GitLab email tokens"
16 task reset_all_email: :environment do
17 reset_all_users_token(:reset_incoming_email_token!)
20 def reset_all_users_token(token)
21 TmpUser.find_in_batches do |batch|
22 puts "Processing batch starting with user ID: #{batch.first.id}"
29 class TmpUser < ActiveRecord::Base
30 include TokenAuthenticatable
32 self.table_name = 'users'
34 def reset_authentication_token!
35 write_new_token(:authentication_token)
36 save!(validate: false)
39 def reset_incoming_email_token!
40 write_new_token(:incoming_email_token)
41 save!(validate: false)