devise_ldap_authenticatable 0.5.0 → 0.5.1
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.
@@ -13,14 +13,6 @@ module Devise
|
|
13
13
|
resource = LdapConnect.new(options)
|
14
14
|
resource.authorized?
|
15
15
|
end
|
16
|
-
|
17
|
-
def self.valid_login?(login)
|
18
|
-
options = {:login => login,
|
19
|
-
:ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
|
20
|
-
:admin => ::Devise.ldap_use_admin_to_bind}
|
21
|
-
resource = LdapConnect.new(options)
|
22
|
-
resource.valid_login?
|
23
|
-
end
|
24
16
|
|
25
17
|
def self.update_password(login, new_password)
|
26
18
|
options = {:login => login,
|
@@ -31,32 +23,36 @@ module Devise
|
|
31
23
|
resource = LdapConnect.new(options)
|
32
24
|
resource.change_password! if new_password.present?
|
33
25
|
end
|
34
|
-
|
35
|
-
def self.
|
26
|
+
|
27
|
+
def self.ldap_connect(login)
|
36
28
|
options = {:login => login,
|
37
29
|
:ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
|
38
30
|
:admin => ::Devise.ldap_use_admin_to_bind}
|
39
31
|
|
40
|
-
|
41
|
-
|
32
|
+
resource = LdapConnect.new(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.valid_login?(login)
|
36
|
+
self.ldap_connect(login).valid_login?
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.get_groups(login)
|
40
|
+
self.ldap_connect(login).user_groups
|
42
41
|
end
|
43
42
|
|
44
43
|
def self.get_dn(login)
|
45
|
-
|
46
|
-
:ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
|
47
|
-
:admin => ::Devise.ldap_use_admin_to_bind}
|
48
|
-
resource = LdapConnect.new(options)
|
49
|
-
resource.dn
|
44
|
+
self.ldap_connect(login).dn
|
50
45
|
end
|
51
46
|
|
52
47
|
def self.get_ldap_param(login,param)
|
53
|
-
|
54
|
-
:ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
|
55
|
-
:admin => ::Devise.ldap_use_admin_to_bind}
|
56
|
-
resource = LdapConnect.new(options)
|
48
|
+
resource = self.ldap_connect(login)
|
57
49
|
resource.ldap_param_value(param)
|
58
50
|
end
|
59
51
|
|
52
|
+
def self.get_ldap_entry(login)
|
53
|
+
self.ldap_connect(login).search_for_login
|
54
|
+
end
|
55
|
+
|
60
56
|
class LdapConnect
|
61
57
|
|
62
58
|
attr_reader :ldap, :login
|
@@ -100,8 +96,19 @@ module Devise
|
|
100
96
|
ldap_entry = nil
|
101
97
|
@ldap.search(:filter => filter) {|entry| ldap_entry = entry}
|
102
98
|
|
103
|
-
|
104
|
-
|
99
|
+
if ldap_entry
|
100
|
+
if ldap_entry[param]
|
101
|
+
DeviseLdapAuthenticatable::Logger.send("Requested param #{param} has value #{ldap_entry.send(param)}")
|
102
|
+
value = ldap_entry.send(param)
|
103
|
+
value = value.first if value.is_a?(Array) and value.count == 1
|
104
|
+
else
|
105
|
+
DeviseLdapAuthenticatable::Logger.send("Requested param #{param} does not exist")
|
106
|
+
value = nil
|
107
|
+
end
|
108
|
+
else
|
109
|
+
DeviseLdapAuthenticatable::Logger.send("Requested ldap entry does not exist")
|
110
|
+
value = nil
|
111
|
+
end
|
105
112
|
end
|
106
113
|
|
107
114
|
def authenticate!
|
@@ -189,6 +196,17 @@ module Devise
|
|
189
196
|
def valid_login?
|
190
197
|
!search_for_login.nil?
|
191
198
|
end
|
199
|
+
|
200
|
+
# Searches the LDAP for the login
|
201
|
+
#
|
202
|
+
# @return [Object] the LDAP entry found; nil if not found
|
203
|
+
def search_for_login
|
204
|
+
DeviseLdapAuthenticatable::Logger.send("LDAP search for login: #{@attribute}=#{@login}")
|
205
|
+
filter = Net::LDAP::Filter.eq(@attribute.to_s, @login.to_s)
|
206
|
+
ldap_entry = nil
|
207
|
+
@ldap.search(:filter => filter) {|entry| ldap_entry = entry}
|
208
|
+
ldap_entry
|
209
|
+
end
|
192
210
|
|
193
211
|
private
|
194
212
|
|
@@ -207,17 +225,6 @@ module Devise
|
|
207
225
|
DeviseLdapAuthenticatable::Logger.send("Finding user: #{dn}")
|
208
226
|
ldap.search(:base => dn, :scope => Net::LDAP::SearchScope_BaseObject).try(:first)
|
209
227
|
end
|
210
|
-
|
211
|
-
# Searches the LDAP for the login
|
212
|
-
#
|
213
|
-
# @return [Object] the LDAP entry found; nil if not found
|
214
|
-
def search_for_login
|
215
|
-
DeviseLdapAuthenticatable::Logger.send("LDAP search for login: #{@attribute}=#{@login}")
|
216
|
-
filter = Net::LDAP::Filter.eq(@attribute.to_s, @login.to_s)
|
217
|
-
ldap_entry = nil
|
218
|
-
@ldap.search(:filter => filter) {|entry| ldap_entry = entry}
|
219
|
-
ldap_entry
|
220
|
-
end
|
221
228
|
|
222
229
|
def update_ldap(ops)
|
223
230
|
operations = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_ldap_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-12-09 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: devise
|
18
|
-
requirement: &
|
18
|
+
requirement: &70110522209540 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 1.5.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70110522209540
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: net-ldap
|
29
|
-
requirement: &
|
29
|
+
requirement: &70110522208060 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 0.2.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70110522208060
|
38
38
|
description: Devise extension to allow authentication via LDAP
|
39
39
|
email: curtis.schiewek@gmail.com
|
40
40
|
executables: []
|
@@ -156,8 +156,85 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 1.8.
|
159
|
+
rubygems_version: 1.8.10
|
160
160
|
signing_key:
|
161
161
|
specification_version: 3
|
162
162
|
summary: Devise extension to allow authentication via LDAP
|
163
|
-
test_files:
|
163
|
+
test_files:
|
164
|
+
- test/devise_ldap_authenticatable_test.rb
|
165
|
+
- test/ldap/base.ldif
|
166
|
+
- test/ldap/clear.ldif
|
167
|
+
- test/ldap/local.schema
|
168
|
+
- test/ldap/openldap-data/run/.gitkeep
|
169
|
+
- test/ldap/run-server.sh
|
170
|
+
- test/ldap/server.pem
|
171
|
+
- test/ldap/slapd-ssl-test.conf
|
172
|
+
- test/ldap/slapd-test.conf
|
173
|
+
- test/rails_app/Gemfile
|
174
|
+
- test/rails_app/Gemfile.lock
|
175
|
+
- test/rails_app/Rakefile
|
176
|
+
- test/rails_app/app/controllers/application_controller.rb
|
177
|
+
- test/rails_app/app/controllers/posts_controller.rb
|
178
|
+
- test/rails_app/app/helpers/application_helper.rb
|
179
|
+
- test/rails_app/app/helpers/posts_helper.rb
|
180
|
+
- test/rails_app/app/models/post.rb
|
181
|
+
- test/rails_app/app/models/user.rb
|
182
|
+
- test/rails_app/app/views/layouts/application.html.erb
|
183
|
+
- test/rails_app/app/views/posts/index.html.erb
|
184
|
+
- test/rails_app/config.ru
|
185
|
+
- test/rails_app/config/application.rb
|
186
|
+
- test/rails_app/config/boot.rb
|
187
|
+
- test/rails_app/config/cucumber.yml
|
188
|
+
- test/rails_app/config/database.yml
|
189
|
+
- test/rails_app/config/environment.rb
|
190
|
+
- test/rails_app/config/environments/development.rb
|
191
|
+
- test/rails_app/config/environments/production.rb
|
192
|
+
- test/rails_app/config/environments/test.rb
|
193
|
+
- test/rails_app/config/initializers/backtrace_silencers.rb
|
194
|
+
- test/rails_app/config/initializers/devise.rb
|
195
|
+
- test/rails_app/config/initializers/inflections.rb
|
196
|
+
- test/rails_app/config/initializers/mime_types.rb
|
197
|
+
- test/rails_app/config/initializers/secret_token.rb
|
198
|
+
- test/rails_app/config/initializers/session_store.rb
|
199
|
+
- test/rails_app/config/ldap.yml
|
200
|
+
- test/rails_app/config/ldap_with_boolean_ssl.yml
|
201
|
+
- test/rails_app/config/ldap_with_erb.yml
|
202
|
+
- test/rails_app/config/ldap_with_uid.yml
|
203
|
+
- test/rails_app/config/locales/devise.en.yml
|
204
|
+
- test/rails_app/config/locales/en.yml
|
205
|
+
- test/rails_app/config/routes.rb
|
206
|
+
- test/rails_app/config/ssl_ldap.yml
|
207
|
+
- test/rails_app/config/ssl_ldap_with_erb.yml
|
208
|
+
- test/rails_app/config/ssl_ldap_with_uid.yml
|
209
|
+
- test/rails_app/db/migrate/20100708120302_create_posts.rb
|
210
|
+
- test/rails_app/db/migrate/20100708120448_devise_create_users.rb
|
211
|
+
- test/rails_app/db/schema.rb
|
212
|
+
- test/rails_app/db/seeds.rb
|
213
|
+
- test/rails_app/features/manage_logins.feature
|
214
|
+
- test/rails_app/features/step_definitions/login_steps.rb
|
215
|
+
- test/rails_app/features/step_definitions/web_steps.rb
|
216
|
+
- test/rails_app/features/support/env.rb
|
217
|
+
- test/rails_app/features/support/paths.rb
|
218
|
+
- test/rails_app/lib/tasks/.gitkeep
|
219
|
+
- test/rails_app/lib/tasks/cucumber.rake
|
220
|
+
- test/rails_app/public/404.html
|
221
|
+
- test/rails_app/public/422.html
|
222
|
+
- test/rails_app/public/500.html
|
223
|
+
- test/rails_app/public/images/rails.png
|
224
|
+
- test/rails_app/public/javascripts/application.js
|
225
|
+
- test/rails_app/public/javascripts/controls.js
|
226
|
+
- test/rails_app/public/javascripts/dragdrop.js
|
227
|
+
- test/rails_app/public/javascripts/effects.js
|
228
|
+
- test/rails_app/public/javascripts/prototype.js
|
229
|
+
- test/rails_app/public/javascripts/rails.js
|
230
|
+
- test/rails_app/public/stylesheets/.gitkeep
|
231
|
+
- test/rails_app/script/cucumber
|
232
|
+
- test/rails_app/script/rails
|
233
|
+
- test/rails_app/test/factories/users.rb
|
234
|
+
- test/rails_app/test/functional/posts_controller_test.rb
|
235
|
+
- test/rails_app/test/performance/browsing_test.rb
|
236
|
+
- test/rails_app/test/test_helper.rb
|
237
|
+
- test/rails_app/test/unit/helpers/posts_helper_test.rb
|
238
|
+
- test/rails_app/test/unit/post_test.rb
|
239
|
+
- test/rails_app/test/unit/user_test.rb
|
240
|
+
- test/test_helper.rb
|