diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-03-14 08:55:50 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-03-14 08:55:50 +0100 |
commit | 56df3dbff2e07f6c4402ff7410412238d643ce0f (patch) | |
tree | d120ff92865fc3d8c52c3aa7e36ed10233396434 | |
parent | af53aa9072ae355b6de167b0d20f9b87195131ec (diff) | |
download | gitlab-ce-56df3dbff2e07f6c4402ff7410412238d643ce0f.tar.gz |
Add Gitlab::LDAP::Access.open
This new method wraps Gitlab::LDAP::Adapter.open to enable connection
reuse.
-rw-r--r-- | lib/gitlab/ldap/access.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/ldap/access.rb b/lib/gitlab/ldap/access.rb index 2a636244473..8f492e5c012 100644 --- a/lib/gitlab/ldap/access.rb +++ b/lib/gitlab/ldap/access.rb @@ -1,8 +1,20 @@ 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) + !!Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter) rescue false end |