From e124f2c1121a3fa638da9489bde894124e8bf709 Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Tue, 26 Jan 2016 23:32:33 +0100 Subject: [PATCH 1/2] Test proper usage of Net::LDAP#encryption --- spec/omniauth-ldap/adaptor_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/omniauth-ldap/adaptor_spec.rb b/spec/omniauth-ldap/adaptor_spec.rb index e6a304f..37ec663 100644 --- a/spec/omniauth-ldap/adaptor_spec.rb +++ b/spec/omniauth-ldap/adaptor_spec.rb @@ -52,6 +52,11 @@ adaptor.connection.instance_variable_get('@auth')[:initial_credential].should =~ /^NTLMSSP/ adaptor.connection.instance_variable_get('@auth')[:challenge_response].should_not be_nil end + + it 'should set the encryption method correctly' do + adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'tls', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName'}) + adaptor.connection.instance_variable_get('@encryption').should include method: :start_tls + end end describe 'bind_as' do From e4318263f9526aa1a61221064d47bcad26363e2a Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Tue, 26 Jan 2016 23:34:37 +0100 Subject: [PATCH 2/2] Use Net::LDAP#encryption properly --- lib/omniauth-ldap/adaptor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/omniauth-ldap/adaptor.rb b/lib/omniauth-ldap/adaptor.rb index 415023c..fd1a333 100644 --- a/lib/omniauth-ldap/adaptor.rb +++ b/lib/omniauth-ldap/adaptor.rb @@ -49,7 +49,6 @@ def initialize(configuration={}) config = { :host => @host, :port => @port, - :encryption => method, :base => @base } @bind_method = @try_sasl ? :sasl : (@allow_anonymous||!@bind_dn||!@password ? :anonymous : :simple) @@ -62,6 +61,7 @@ def initialize(configuration={}) } config[:auth] = @auth @connection = Net::LDAP.new(config) + @connection.encryption(method) end #:base => "dc=yourcompany, dc=com",