mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-01 16:46:16 +00:00
18 lines
340 B
Ruby
18 lines
340 B
Ruby
# 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|
|
|
subjects[key.upcase] = value if key.upcase.start_with?(*search_keys.map(&:upcase))
|
|
end
|
|
|
|
subjects
|
|
rescue StandardError
|
|
{}
|
|
end
|
|
end
|