gitlab_omniauth-ldap 2.0.3 → 2.0.4

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: ac7ceaa4ec67ee276ca4d7f8c20bc1326f31fc3f
4
- data.tar.gz: 43ac5e5252e03e8780695d7a05c15aa0c2f4df0a
3
+ metadata.gz: 4d5b4eb5376fab8ef4f9e5e006ba83aa214402e0
4
+ data.tar.gz: 372d5d8f78a286cfe1328695f11323704a8297b6
5
5
  SHA512:
6
- metadata.gz: b772560d1bdf110ce019fddc837e0332cd9449934f20deed0bbf034c91fe683f19f1a492f258ebd86f920427c4813227669a18a05b955cd2f4c3bd4538c7665e
7
- data.tar.gz: bd91d1d785dd0931e3c2602622324eec46017c9b91d30b695d6edbacb1cb920b2a8ff80855d97363b59873dee1bfe50ee152a1f25da9a86e2ebd9b17fa29c0d6
6
+ metadata.gz: e2154945f44fa50434692911fafa1fdc098d4758603c6391be558b701ae4f87b712aef88501c98fa00dda0160e74995172067f9c24f97b051da29e8145f4e0bf
7
+ data.tar.gz: 5d9b8cd9c5e488f1a643c6bae705f79290bcf04588a50e638bc1d6a80e2d67ba3fedfd122d4ca405b32e58a7fa0edcd0f58ef6736dba02876bf7bfdfab122e4e
data/CHANGELOG CHANGED
@@ -1,2 +1,5 @@
1
+ ## 2.0.4
2
+ - Improve log message when invalid credentials are used
3
+
1
4
  ## 2.0.3
2
5
  - Protects against wrong request method call to callback
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module LDAP
3
- VERSION = "2.0.3"
3
+ VERSION = "2.0.4"
4
4
  end
5
5
  end
@@ -4,6 +4,9 @@ module OmniAuth
4
4
  module Strategies
5
5
  class LDAP
6
6
  include OmniAuth::Strategy
7
+
8
+ InvalidCredentialsError = Class.new(StandardError)
9
+
7
10
  @@config = {
8
11
  'name' => 'cn',
9
12
  'first_name' => 'givenName',
@@ -45,7 +48,9 @@ module OmniAuth
45
48
  begin
46
49
  @ldap_user_info = @adaptor.bind_as(:filter => filter(@adaptor), :size => 1, :password => request['password'])
47
50
 
48
- return fail!(:invalid_credentials) if !@ldap_user_info
51
+ unless @ldap_user_info
52
+ return fail!(:invalid_credentials, InvalidCredentialsError.new("Invalid credentials for #{request['username']}"))
53
+ end
49
54
 
50
55
  @user_info = self.class.map_user(@@config, @ldap_user_info)
51
56
  super
@@ -54,7 +59,7 @@ module OmniAuth
54
59
  end
55
60
  end
56
61
 
57
- def filter adaptor
62
+ def filter(adaptor)
58
63
  if adaptor.filter and !adaptor.filter.empty?
59
64
  username = Net::LDAP::Filter.escape(@options[:name_proc].call(request['username']))
60
65
  Net::LDAP::Filter.construct(adaptor.filter % { username: username })
@@ -69,8 +69,10 @@ describe "OmniAuth::Strategies::LDAP" do
69
69
 
70
70
  it 'should redirect to error page' do
71
71
  post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
72
- last_response.should be_redirect
73
- last_response.headers['Location'].should =~ %r{invalid_credentials}
72
+
73
+ expect(last_response).to be_redirect
74
+ expect(last_response.headers['Location']).to match('invalid_credentials')
75
+ expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
74
76
  end
75
77
 
76
78
  it 'should redirect to error page when there is exception' do
@@ -132,8 +134,9 @@ describe "OmniAuth::Strategies::LDAP" do
132
134
  it 'should redirect to error page' do
133
135
  post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
134
136
 
135
- last_response.should be_redirect
136
- last_response.headers['Location'].should =~ %r{invalid_credentials}
137
+ expect(last_response).to be_redirect
138
+ expect(last_response.headers['Location']).to match('invalid_credentials')
139
+ expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
137
140
  end
138
141
  context 'and filter is set' do
139
142
  it 'should bind with filter' do
@@ -141,8 +144,9 @@ describe "OmniAuth::Strategies::LDAP" do
141
144
  Net::LDAP::Filter.should_receive(:construct).with('uid=ping')
142
145
  post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
143
146
 
144
- last_response.should be_redirect
145
- last_response.headers['Location'].should =~ %r{invalid_credentials}
147
+ expect(last_response).to be_redirect
148
+ expect(last_response.headers['Location']).to match('invalid_credentials')
149
+ expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
146
150
  end
147
151
  end
148
152
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_omniauth-ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ping Yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-20 00:00:00.000000000 Z
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  requirements: []
174
174
  rubyforge_project:
175
- rubygems_version: 2.5.1
175
+ rubygems_version: 2.6.8
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: A LDAP strategy for OmniAuth.