Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 09:08:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-10 09:08:07 +0300
commit232655bf32cd474d54de357b65ef43d77271117c (patch)
treed176e36660e41bb2b629237639015d4dde7d4414 /app/helpers/x509_helper.rb
parentf5ae9d0960aa422a65a2a22e230100257dddb9ed (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/x509_helper.rb')
-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