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 'app/services/keys/revoke_service.rb')
-rw-r--r--app/services/keys/revoke_service.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/services/keys/revoke_service.rb b/app/services/keys/revoke_service.rb
new file mode 100644
index 00000000000..42ea9ab73be
--- /dev/null
+++ b/app/services/keys/revoke_service.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Keys
+ class RevokeService < ::Keys::DestroyService
+ def execute(key)
+ key.transaction do
+ unverify_associated_signatures(key)
+
+ raise ActiveRecord::Rollback unless super(key)
+ end
+ end
+
+ private
+
+ def unverify_associated_signatures(key)
+ return unless Feature.enabled?(:revoke_ssh_signatures)
+
+ key.ssh_signatures.each_batch do |batch|
+ batch.update_all(
+ verification_status: CommitSignatures::SshSignature.verification_statuses[:revoked_key],
+ updated_at: Time.zone.now
+ )
+ end
+ end
+ end
+end
+
+Keys::DestroyService.prepend_mod