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 'lib/gitlab/background_migration/expire_o_auth_tokens.rb')
-rw-r--r--lib/gitlab/background_migration/expire_o_auth_tokens.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/expire_o_auth_tokens.rb b/lib/gitlab/background_migration/expire_o_auth_tokens.rb
new file mode 100644
index 00000000000..595e4ac9dc8
--- /dev/null
+++ b/lib/gitlab/background_migration/expire_o_auth_tokens.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # Add expiry to all OAuth access tokens
+ class ExpireOAuthTokens < ::Gitlab::BackgroundMigration::BatchedMigrationJob
+ def perform
+ each_sub_batch(
+ operation_name: :update_oauth_tokens,
+ batching_scope: ->(relation) { relation.where(expires_in: nil) }
+ ) do |sub_batch|
+ update_oauth_tokens(sub_batch)
+ end
+ end
+
+ private
+
+ def update_oauth_tokens(relation)
+ relation.update_all(expires_in: 7_200)
+ end
+ end
+ end
+end