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:
Diffstat (limited to 'lib/gitlab/ldap/access.rb')
-rw-r--r--lib/gitlab/ldap/access.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/ldap/access.rb b/lib/gitlab/ldap/access.rb
new file mode 100644
index 00000000000..8f492e5c012
--- /dev/null
+++ b/lib/gitlab/ldap/access.rb
@@ -0,0 +1,23 @@
+module Gitlab
+ module LDAP
+ class Access
+ attr_reader :adapter
+
+ def self.open(&block)
+ Gitlab::LDAP::Adapter.open do |adapter|
+ block.call(self.new(adapter))
+ end
+ end
+
+ def initialize(adapter=nil)
+ @adapter = adapter
+ end
+
+ def allowed?(user)
+ !!Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
+ rescue
+ false
+ end
+ end
+ end
+end