ons-ldap 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/ons-ldap/ldap_connection.rb +5 -2
- data/lib/ons-ldap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 318abe639b4cf840e6af859cb719ed3af355841f
|
4
|
+
data.tar.gz: 64a36ab8ac6206948e509a6f82aaf5c632292df9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = '
|
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,
|
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})"
|
data/lib/ons-ldap/version.rb
CHANGED
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.
|
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:
|
12
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ldap
|