ons-ldap 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2d412ce6348a1a3eefe1ff3bc96a1fac4f980f9
4
- data.tar.gz: d77ef02808888a498f15a5970861faac220e958e
3
+ metadata.gz: 318abe639b4cf840e6af859cb719ed3af355841f
4
+ data.tar.gz: 64a36ab8ac6206948e509a6f82aaf5c632292df9
5
5
  SHA512:
6
- metadata.gz: 811b492711c0b3a4cb97a54717fc2ad486daf1acbc33f65cfc7436a56aad8943063ec9df5d27b6546d119d44b761f9124256115ae75bd14df17f50b9ad1472c2
7
- data.tar.gz: 43fb9137d557753022d7203e4314fccf2ad1b5aef4a9de4a621f5fce4f360deba45ea2076f72b31e2e3337c1c408b67eebe5bc21965851a7bd17ec4797ff348c
6
+ metadata.gz: a4beaf49ed2ac8584a74296d3a7777d2cf3961f7f27cf9433004f8a37564ee492a2c32a1b75c9f707d076a8d2a82abe53ea004a8d63119d7d3905945d108e789
7
+ data.tar.gz: 07f785d601d34bf5d360dd534f08f75fbac527770cc66bfca49a592dca9b460d85d112f8ec1446392e459736b559dec8fc3ca4f0996c489b6de84e66e435c5ba
data/README.md CHANGED
@@ -13,7 +13,7 @@ gem install ons-ldap
13
13
  require 'ons-ldap'
14
14
 
15
15
  host = 'localhost ' # LDAP server host
16
- port = '398' # LDAP server port
16
+ port = '636' # LDAP server port (LDAPS)
17
17
  base = 'dc=example,dc=com' # LDAP tree base
18
18
 
19
19
  # Hash of LDAP group names.
@@ -26,6 +26,9 @@ user_entry.user_id #=> 'johntopley'
26
26
  user_entry.display_name #=> 'John Topley'
27
27
  user_entry.token # 2FA token, stored in LDAP's employeeNumber field for expediency
28
28
  user_entry.groups #=> ['admins', 'users']
29
+
30
+ # Pass false as the last initializer argument to use a non-TLS connection:
31
+ ldap_connection = LDAPConnection.new(host, port, base, groups, logger, false)
29
32
  ```
30
33
 
31
34
  ## Testing
@@ -11,14 +11,16 @@ class LDAPConnection
11
11
  attr_accessor :base
12
12
  attr_accessor :groups
13
13
  attr_accessor :logger
14
+ attr_accessor :encrypted
14
15
  end
15
16
 
16
- def initialize(host, port, base, groups, logger)
17
+ def initialize(host, port, base, groups, logger, encrypted = true)
17
18
  self.class.host = host
18
19
  self.class.port = port.to_i
19
20
  self.class.base = base
20
21
  self.class.groups = groups
21
22
  self.class.logger = logger
23
+ self.class.encrypted = encrypted
22
24
  end
23
25
 
24
26
  def authenticate(username, password)
@@ -27,7 +29,8 @@ class LDAPConnection
27
29
  # Have to use the username DN format below for the bind operation to succeed.
28
30
  auth = { method: :simple, username: "uid=#{username},ou=Users,#{self.class.base}", password: password }
29
31
 
30
- Net::LDAP.open(host: self.class.host, port: self.class.port, base: self.class.base, auth: auth) do |ldap|
32
+ Net::LDAP.open(host: self.class.host, port: self.class.port, self.class.base, auth: auth) do |ldap|
33
+ ldap.encryption = :simple_tls if self.class.encrypted?
31
34
  unless ldap.bind
32
35
  result = ldap.get_operation_result
33
36
  self.class.logger.error "LDAP authentication failed for '#{username}': #{result.message} (#{result.code})"
@@ -1,7 +1,7 @@
1
1
  module ONSLDAP
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
5
5
  TINY = 0
6
6
  end
7
7
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ons-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Topley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-25 00:00:00.000000000 Z
12
+ date: 2017-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ldap