summaryrefslogtreecommitdiff
path: root/app/models/gpg_signature.rb
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-10-04 18:44:49 -0500
committerRubén Dávila <ruben@gitlab.com>2017-10-05 08:26:02 -0500
commitdd139e65b53f30eae2d8bb50dff180e8eab11fe4 (patch)
tree32411533b4ccfdfb6a2f08e2df0f2bb2b383e61d /app/models/gpg_signature.rb
parent2577cc99818bd0332aa78018de666579971341c8 (diff)
downloadgitlab-ce-dd139e65b53f30eae2d8bb50dff180e8eab11fe4.tar.gz
Invalidate GpgSignatures associated to GpgKeySubkeys when revoking the GpgKey
Diffstat (limited to 'app/models/gpg_signature.rb')
-rw-r--r--app/models/gpg_signature.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb
index e783c3b24e4..b718e8e1000 100644
--- a/app/models/gpg_signature.rb
+++ b/app/models/gpg_signature.rb
@@ -21,6 +21,19 @@ class GpgSignature < ActiveRecord::Base
validates :project_id, presence: true
validates :gpg_key_primary_keyid, presence: true
+ def self.with_key_and_subkeys(gpg_key)
+ return none unless gpg_key
+
+ t = arel_table
+ subkey_ids = gpg_key&.subkeys&.pluck(:id)
+
+ where(
+ t[:gpg_key_id].eq(gpg_key&.id).or(
+ t[:gpg_key_subkey_id].in(subkey_ids)
+ )
+ )
+ end
+
def gpg_key=(model)
case model
when GpgKey