2022-05-12 09:08:08 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module BackgroundMigration
|
|
|
|
# Add expiry to all OAuth access tokens
|
|
|
|
class ExpireOAuthTokens < ::Gitlab::BackgroundMigration::BatchedMigrationJob
|
2022-10-24 21:09:11 +00:00
|
|
|
operation_name :update_oauth_tokens
|
|
|
|
|
2022-05-13 12:08:49 +00:00
|
|
|
def perform
|
2022-05-12 09:08:08 +00:00
|
|
|
each_sub_batch(
|
|
|
|
batching_scope: ->(relation) { relation.where(expires_in: nil) }
|
|
|
|
) do |sub_batch|
|
2022-05-13 12:08:49 +00:00
|
|
|
update_oauth_tokens(sub_batch)
|
2022-05-12 09:08:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2022-05-13 12:08:49 +00:00
|
|
|
def update_oauth_tokens(relation)
|
2022-05-12 09:08:08 +00:00
|
|
|
relation.update_all(expires_in: 7_200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|