summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 06:08:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 06:08:07 +0000
commit232655bf32cd474d54de357b65ef43d77271117c (patch)
treed176e36660e41bb2b629237639015d4dde7d4414 /app/helpers
parentf5ae9d0960aa422a65a2a22e230100257dddb9ed (diff)
downloadgitlab-ce-232655bf32cd474d54de357b65ef43d77271117c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/x509_helper.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/x509_helper.rb b/app/helpers/x509_helper.rb
new file mode 100644
index 00000000000..c330b599d74
--- /dev/null
+++ b/app/helpers/x509_helper.rb
@@ -0,0 +1,19 @@
+# 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
+ rescue
+ {}
+ end
+end