2020-03-10 02:08:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'net/ldap/dn'
|
|
|
|
|
|
|
|
module X509Helper
|
|
|
|
def x509_subject(subject, search_keys)
|
|
|
|
subjects = {}
|
|
|
|
|
|
|
|
Net::LDAP::DN.new(subject).each_pair do |key, value|
|
|
|
|
if key.upcase.start_with?(*search_keys.map(&:upcase))
|
|
|
|
subjects[key.upcase] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
subjects
|
2021-04-26 08:09:44 -04:00
|
|
|
rescue StandardError
|
2020-03-10 02:08:07 -04:00
|
|
|
{}
|
|
|
|
end
|
2020-05-06 17:10:00 -04:00
|
|
|
|
|
|
|
def x509_signature?(sig)
|
2021-12-13 07:12:59 -05:00
|
|
|
sig.is_a?(CommitSignatures::X509CommitSignature) || sig.is_a?(Gitlab::X509::Signature)
|
2020-05-06 17:10:00 -04:00
|
|
|
end
|
2020-03-10 02:08:07 -04:00
|
|
|
end
|