Commit 56df3dbff2e07f6c4402ff7410412238d643ce0f
1 parent
af53aa90
Exists in
spb-stable
and in
3 other branches
Add Gitlab::LDAP::Access.open
This new method wraps Gitlab::LDAP::Adapter.open to enable connection reuse.
Showing
1 changed file
with
13 additions
and
1 deletions
Show diff stats
lib/gitlab/ldap/access.rb
1 | 1 | module Gitlab |
2 | 2 | module LDAP |
3 | 3 | class Access |
4 | + attr_reader :adapter | |
5 | + | |
6 | + def self.open(&block) | |
7 | + Gitlab::LDAP::Adapter.open do |adapter| | |
8 | + block.call(self.new(adapter)) | |
9 | + end | |
10 | + end | |
11 | + | |
12 | + def initialize(adapter=nil) | |
13 | + @adapter = adapter | |
14 | + end | |
15 | + | |
4 | 16 | def allowed?(user) |
5 | - !!Gitlab::LDAP::Person.find_by_dn(user.extern_uid) | |
17 | + !!Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter) | |
6 | 18 | rescue |
7 | 19 | false |
8 | 20 | end | ... | ... |