sheffield_ldap_lookup 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1fb61d37a5823114d379ab1a345d184b1c35b17
4
- data.tar.gz: 86156649e10b28a2ff876a165a86eb15ca25b97c
3
+ metadata.gz: 53101ae7dab529fac6ee8e5604ccf548fce20a75
4
+ data.tar.gz: 593b21537e0c2024e2c000a5384b34ba225b2403
5
5
  SHA512:
6
- metadata.gz: 080c9715362eb34846ec609100cfc7ba7936caa346d8ad99f6a0d9d45d03823a171b245d03f1646a3e3417b7d28ac3feff62d3976e9a889f7ed718950ea33051
7
- data.tar.gz: 0116b41bd5caa1e52ced95c481721c1641669af4838b76207ba581a1d5234b725db5e0fc709568f2fa6f592b280cc5c8665d082e365d2935944f5f76f586023f
6
+ metadata.gz: 3807d07547fc71d68186c9c8569a86a58fc3eaafd1247642d23c37042b425439967104fb72c33e10866d2ef8be851382e420757d0f4b8dc23c33e814ac50ac7b
7
+ data.tar.gz: c3a998108c0c650e1af430541bc147a81d6dec782381336f2d4e3d042c45d3725db48f490a8086c2afa4d0b494be0862efca8751f54142c9a921e1e39f7b8be5
@@ -2,16 +2,18 @@ require 'net/ldap'
2
2
  module SheffieldLdapLookup
3
3
  class LdapFinder
4
4
  attr_accessor :keyword
5
-
6
- def initialize(keyword = nil, config_prefix = nil)
5
+ attr_accessor :custom_search_attribute
6
+
7
+ def initialize(keyword = nil, config_prefix = nil, custom_search_attribute = nil)
7
8
  self.keyword = keyword
8
9
  @config_prefix = config_prefix
10
+ self.custom_search_attribute = custom_search_attribute
9
11
  end
10
-
12
+
11
13
  class << self
12
14
  attr_accessor :ldap_config
13
15
  end
14
-
16
+
15
17
  def lookup
16
18
  begin
17
19
  @lookup ||= connection.search(filter: ldap_filter)[0]
@@ -25,6 +27,7 @@ module SheffieldLdapLookup
25
27
  end
26
28
 
27
29
  def search_attribute
30
+ return custom_search_attribute if custom_search_attribute
28
31
  keyword =~ /\A[^@]+@[^@]+\z/ ? 'mail' : 'uid'
29
32
  end
30
33
 
@@ -35,12 +38,12 @@ module SheffieldLdapLookup
35
38
  def connection(ldap_class = Net::LDAP)
36
39
  @connection ||= ldap_class.new(connection_settings)
37
40
  end
38
-
41
+
39
42
  def connection_settings
40
43
  base_settings = {
41
44
  host: ldap_config["#{@config_prefix}host"], port: ldap_config["#{@config_prefix}port"], base: ldap_config["#{@config_prefix}base"]
42
45
  }
43
-
46
+
44
47
  if ldap_config.key?("#{@config_prefix}username") && ldap_config.key?("#{@config_prefix}password")
45
48
  base_settings[:auth] = {
46
49
  method: :simple,
@@ -50,6 +53,6 @@ module SheffieldLdapLookup
50
53
  end
51
54
  base_settings
52
55
  end
53
-
56
+
54
57
  end
55
58
  end
@@ -1,3 +1,3 @@
1
1
  module SheffieldLdapLookup
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheffield_ldap_lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuo Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ldap
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.2.2
110
+ rubygems_version: 2.4.6
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: LDAP lookup