net-ldap 0.17.1 → 0.19.0

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
  SHA256:
3
- metadata.gz: 55f2964276a686be8ca816c32c499383b0085f0f20c9af76fb039ce0df9bc3c0
4
- data.tar.gz: fd9caa7e812f4de283cc07aefc56707f47215924a50f524beda08b72cc7bd9a3
3
+ metadata.gz: 1fdcc1a3fefe3fb2bf1dbb91ec9e00734252fdda634ae0e2344b9dd6e6b86cd2
4
+ data.tar.gz: 8526bd506b632e74193c80119280fd4b333731b1e3d75791427a12e62cab775a
5
5
  SHA512:
6
- metadata.gz: 827e26be88d21d2a46b4912cf77c86cd523e3267cf7a6db62eb2a841ef655dd885a979f79479895a65eabe37e54d980b7abb16d134c7c73b4cf73ade9a7c01b6
7
- data.tar.gz: a796f5aebdf10570f0b762b603bcc9668a8a5b6a592866dc8af4e19ec92e01fb0def0c4e3d2199955b68ead95ec3cd09d2602ac2e27bfa02fc292bfe284486b6
6
+ metadata.gz: e2f9e53240eeedd964463c6bc719cc86e57e5a66c5a769371e16d97005f9b63933797f33384e0192b6e128cc4fec1de46e3cca2886fce963439d86b4b3c0665f
7
+ data.tar.gz: e4af635dce612600ba48a110ebae1d3c30c00f9c5adcfeba1b6eca1d4d760646674d399cac256f96490bcad6d884146cb891ac14d57f8734556ed7e331baac90
data/History.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ === Net::LDAP 0.19.0
2
+ * Net::LDAP::DN - Retain trailing spaces in RDN values in DNs #412
3
+ * Add in ability for users to specify LDAP controls when conducting searches #411
4
+ * Document connect_timeout in Constructor Details #415
5
+ * Fix openssl error when using multiple hosts #417
6
+
7
+ === Net::LDAP 0.18.0
8
+ * Fix escaping of # and space in attrs #408
9
+ * Add support to use SNI #406
10
+ * Drop Ruby 2.5 and JRuby 9.2 from CI tests
11
+ * Bump rubocop to 1.48.1
12
+ * Update CI for TruffleRuby 22
13
+
1
14
  === Net::LDAP 0.17.1
2
15
  * Fixed shebang of bash #385
3
16
  * Omit some tests for now until we update our CA cert #386
@@ -30,12 +30,12 @@ class Net::LDAP::Connection #:nodoc:
30
30
  @socket_class = socket_class
31
31
  end
32
32
 
33
- def prepare_socket(server, timeout=nil)
33
+ def prepare_socket(server, timeout=nil, hostname='127.0.0.1')
34
34
  socket = server[:socket]
35
35
  encryption = server[:encryption]
36
36
 
37
37
  @conn = socket
38
- setup_encryption(encryption, timeout) if encryption
38
+ setup_encryption(encryption, timeout, hostname) if encryption
39
39
  end
40
40
 
41
41
  def open_connection(server)
@@ -50,7 +50,7 @@ class Net::LDAP::Connection #:nodoc:
50
50
  errors = []
51
51
  hosts.each do |host, port|
52
52
  begin
53
- prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout)
53
+ prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout, host)
54
54
  if encryption
55
55
  if encryption[:tls_options] &&
56
56
  encryption[:tls_options][:verify_mode] &&
@@ -86,7 +86,7 @@ class Net::LDAP::Connection #:nodoc:
86
86
  end
87
87
  end
88
88
 
89
- def self.wrap_with_ssl(io, tls_options = {}, timeout=nil)
89
+ def self.wrap_with_ssl(io, tls_options = {}, timeout=nil, hostname=nil)
90
90
  raise Net::LDAP::NoOpenSSLError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
91
91
 
92
92
  ctx = OpenSSL::SSL::SSLContext.new
@@ -96,6 +96,7 @@ class Net::LDAP::Connection #:nodoc:
96
96
  ctx.set_params(tls_options) unless tls_options.empty?
97
97
 
98
98
  conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
99
+ conn.hostname = hostname
99
100
 
100
101
  begin
101
102
  if timeout
@@ -148,11 +149,11 @@ class Net::LDAP::Connection #:nodoc:
148
149
  # communications, as with simple_tls. Thanks for Kouhei Sutou for
149
150
  # generously contributing the :start_tls path.
150
151
  #++
151
- def setup_encryption(args, timeout=nil)
152
+ def setup_encryption(args, timeout=nil, hostname=nil)
152
153
  args[:tls_options] ||= {}
153
154
  case args[:method]
154
155
  when :simple_tls
155
- @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
156
+ @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname)
156
157
  # additional branches requiring server validation and peer certs, etc.
157
158
  # go here.
158
159
  when :start_tls
@@ -170,7 +171,7 @@ class Net::LDAP::Connection #:nodoc:
170
171
 
171
172
  raise Net::LDAP::StartTLSError,
172
173
  "start_tls failed: #{pdu.result_code}" unless pdu.result_code.zero?
173
- @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
174
+ @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname)
174
175
  else
175
176
  raise Net::LDAP::EncMethodUnsupportedError, "unsupported encryption method #{args[:method]}"
176
177
  end
@@ -423,6 +424,7 @@ class Net::LDAP::Connection #:nodoc:
423
424
  # this breaks when calling to_ber. (Can't force binary data to UTF-8)
424
425
  # we have to disable paging (even though server supports it) to get around this...
425
426
 
427
+ user_controls = args.fetch(:controls, [])
426
428
  controls = []
427
429
  controls <<
428
430
  [
@@ -432,7 +434,12 @@ class Net::LDAP::Connection #:nodoc:
432
434
  rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber,
433
435
  ].to_ber_sequence if paged
434
436
  controls << ber_sort if ber_sort
435
- controls = controls.empty? ? nil : controls.to_ber_contextspecific(0)
437
+ if controls.empty? && user_controls.empty?
438
+ controls = nil
439
+ else
440
+ controls += user_controls
441
+ controls = controls.to_ber_contextspecific(0)
442
+ end
436
443
 
437
444
  write(request, controls, message_id)
438
445
 
data/lib/net/ldap/dn.rb CHANGED
@@ -81,7 +81,7 @@ class Net::LDAP::DN
81
81
  value << char
82
82
  when ',' then
83
83
  state = :key
84
- yield key.string.strip, value.string.rstrip
84
+ yield key.string.strip, value.string
85
85
  key = StringIO.new
86
86
  value = StringIO.new;
87
87
  else
@@ -93,7 +93,7 @@ class Net::LDAP::DN
93
93
  when '\\' then state = :value_normal_escape
94
94
  when ',' then
95
95
  state = :key
96
- yield key.string.strip, value.string.rstrip
96
+ yield key.string.strip, value.string
97
97
  key = StringIO.new
98
98
  value = StringIO.new;
99
99
  else value << char
@@ -142,7 +142,7 @@ class Net::LDAP::DN
142
142
  when ' ' then state = :value_end
143
143
  when ',' then
144
144
  state = :key
145
- yield key.string.strip, value.string.rstrip
145
+ yield key.string.strip, value.string
146
146
  key = StringIO.new
147
147
  value = StringIO.new;
148
148
  else raise Net::LDAP::InvalidDNError, "DN badly formed"
@@ -159,7 +159,7 @@ class Net::LDAP::DN
159
159
  when ' ' then state = :value_end
160
160
  when ',' then
161
161
  state = :key
162
- yield key.string.strip, value.string.rstrip
162
+ yield key.string.strip, value.string
163
163
  key = StringIO.new
164
164
  value = StringIO.new;
165
165
  else raise Net::LDAP::InvalidDNError, "DN badly formed"
@@ -172,7 +172,7 @@ class Net::LDAP::DN
172
172
  raise Net::LDAP::InvalidDNError, "DN badly formed" unless
173
173
  [:value, :value_normal, :value_hexstring, :value_end].include? state
174
174
 
175
- yield key.string.strip, value.string.rstrip
175
+ yield key.string.strip, value.string
176
176
  end
177
177
 
178
178
  ##
@@ -192,27 +192,19 @@ class Net::LDAP::DN
192
192
  # http://tools.ietf.org/html/rfc2253 section 2.4 lists these exceptions
193
193
  # for dn values. All of the following must be escaped in any normal string
194
194
  # using a single backslash ('\') as escape.
195
- ESCAPES = {
196
- ',' => ',',
197
- '+' => '+',
198
- '"' => '"',
199
- '\\' => '\\',
200
- '<' => '<',
201
- '>' => '>',
202
- ';' => ';',
203
- }
195
+ ESCAPES = %w[, + " \\ < > ;]
204
196
 
205
- # Compiled character class regexp using the keys from the above hash, and
197
+ # Compiled character class regexp using the values from the above list, and
206
198
  # checking for a space or # at the start, or space at the end, of the
207
199
  # string.
208
200
  ESCAPE_RE = Regexp.new("(^ |^#| $|[" +
209
- ESCAPES.keys.map { |e| Regexp.escape(e) }.join +
201
+ ESCAPES.map { |e| Regexp.escape(e) }.join +
210
202
  "])")
211
203
 
212
204
  ##
213
205
  # Escape a string for use in a DN value
214
206
  def self.escape(string)
215
- string.gsub(ESCAPE_RE) { |char| "\\" + ESCAPES[char] }
207
+ string.gsub(ESCAPE_RE) { |char| "\\" + char }
216
208
  end
217
209
 
218
210
  ##
@@ -1,5 +1,5 @@
1
1
  module Net
2
2
  class LDAP
3
- VERSION = "0.17.1"
3
+ VERSION = "0.19.0"
4
4
  end
5
5
  end
data/lib/net/ldap.rb CHANGED
@@ -480,6 +480,8 @@ class Net::LDAP
480
480
  # server says it supports them. This is a fix for MS Active Directory
481
481
  # * :instrumentation_service => An object responsible for instrumenting
482
482
  # operations, compatible with ActiveSupport::Notifications' public API.
483
+ # * :connect_timeout => The TCP socket timeout (in seconds) to use when
484
+ # connecting to the LDAP server (default 5 seconds).
483
485
  # * :encryption => specifies the encryption to be used in communicating
484
486
  # with the LDAP server. The value must be a Hash containing additional
485
487
  # parameters, which consists of two keys:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -10,10 +10,10 @@ authors:
10
10
  - Kaspar Schiess
11
11
  - Austin Ziegler
12
12
  - Michael Schaarschmidt
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2022-06-07 00:00:00.000000000 Z
16
+ date: 2024-01-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: flexmock
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: 0.49.0
52
+ version: '1.48'
53
53
  type: :development
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.49.0
59
+ version: '1.48'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: test-unit
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +146,7 @@ homepage: http://github.com/ruby-ldap/ruby-net-ldap
146
146
  licenses:
147
147
  - MIT
148
148
  metadata: {}
149
- post_install_message:
149
+ post_install_message:
150
150
  rdoc_options:
151
151
  - "--main"
152
152
  - README.rdoc
@@ -163,8 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.3.7
167
- signing_key:
166
+ rubygems_version: 3.4.14
167
+ signing_key:
168
168
  specification_version: 4
169
169
  summary: Net::LDAP for Ruby (also called net-ldap) implements client access for the
170
170
  Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing