Add ability to include subkeys when finding by fingerprint
This commit is contained in:
parent
d0572d9aad
commit
a41e7e0105
2 changed files with 12 additions and 1 deletions
|
@ -40,6 +40,17 @@ class GpgKey < ActiveRecord::Base
|
|||
after_commit :update_invalid_gpg_signatures, on: :create
|
||||
after_create :generate_subkeys
|
||||
|
||||
def self.find_with_subkeys(fingerprint)
|
||||
keys_table = arel_table
|
||||
subkeys_table = GpgKeySubkey.arel_table
|
||||
|
||||
condition = keys_table[:primary_keyid].eq(fingerprint).or(
|
||||
subkeys_table[:keyid].eq(fingerprint)
|
||||
)
|
||||
|
||||
joins(:subkeys).where(condition).first
|
||||
end
|
||||
|
||||
def primary_keyid
|
||||
super&.upcase
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ module Gitlab
|
|||
# key belonging to the keyid.
|
||||
# This way we can add the key to the temporary keychain and extract
|
||||
# the proper signature.
|
||||
gpg_key = GpgKey.find_by(primary_keyid: verified_signature.fingerprint)
|
||||
gpg_key = GpgKey.find_with_subkeys(verified_signature.fingerprint)
|
||||
|
||||
if gpg_key
|
||||
Gitlab::Gpg::CurrentKeyChain.add(gpg_key.key)
|
||||
|
|
Loading…
Reference in a new issue