devise_ldap_authenticatable 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,7 +50,7 @@ then the model :
50
50
  devise :ldap_authenticatable, :rememberable, :trackable, :timeoutable
51
51
 
52
52
  # Setup accessible (or protected) attributes for your model
53
- attr_accessible :login, :password, :remember_me
53
+ attr_accessible :login, :ldap_attributes, :password, :remember_me
54
54
  ...
55
55
  end
56
56
 
@@ -62,16 +62,18 @@ and finally change the authentication key in the devise initializer :
62
62
  ...
63
63
  end
64
64
 
65
+ The string stored in ldap_attributes will be inserted between the login and base to provide the full dn used to bind.
65
66
  I recommend using :rememberable, :trackable, :timeoutable as it gives a full feature set for logins.
66
67
 
67
68
  Usage
68
69
  -----
69
70
 
70
- Devise LDAP Authenticatable works in replacement of Authenticatable, allowing for LDAP authentication via simple bind. The standard sign\_in routes and views work out of the box as these are just reused from devise. I recommend you run :
71
+ Devise LDAP Authenticatable works in replacement of Authenticatable,
72
+ but because we have to change the authentication\_keys, you'll need to run:
71
73
 
72
74
  script/generate devise_views
73
75
 
74
- so you can customize your login pages.
76
+ and customize your login pages to use :login, instead of :email.
75
77
 
76
78
  ------------------------------------------------------------
77
79
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.6
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{devise_ldap_authenticatable}
8
+ s.version = "0.1.6"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Curtis Schiewek"]
12
+ s.date = %q{2010-07-22}
13
+ s.description = %q{LDAP authentication module for Devise}
14
+ s.email = %q{curtis.schiewek@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "MIT-LICENSE",
20
+ "README.md",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "devise_ldap_authenticatable.gemspec",
24
+ "lib/devise_ldap_authenticatable.rb",
25
+ "lib/devise_ldap_authenticatable/ldap_adapter.rb",
26
+ "lib/devise_ldap_authenticatable/model.rb",
27
+ "lib/devise_ldap_authenticatable/routes.rb",
28
+ "lib/devise_ldap_authenticatable/schema.rb",
29
+ "lib/devise_ldap_authenticatable/strategy.rb",
30
+ "rails/init.rb",
31
+ "test/devise_ldap_authenticatable_test.rb",
32
+ "test/test_helper.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/cschiewek/devise_ldap_authenticatable}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{LDAP authentication module for Devise}
39
+ s.test_files = [
40
+ "test/devise_ldap_authenticatable_test.rb",
41
+ "test/test_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<devise>, ["> 1.0.4"])
50
+ s.add_runtime_dependency(%q<net-ldap>, [">= 0.0.0"])
51
+ else
52
+ s.add_dependency(%q<devise>, ["> 1.0.4"])
53
+ s.add_dependency(%q<net-ldap>, [">= 0.0.0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<devise>, ["> 1.0.4"])
57
+ s.add_dependency(%q<net-ldap>, [">= 0.0.0"])
58
+ end
59
+ end
60
+
@@ -6,8 +6,10 @@ module Devise
6
6
  # ::Devise.ldap_host
7
7
  module LdapAdapter
8
8
 
9
- def self.valid_credentials?(login, password)
10
- login = ::Devise.ldap_login_attribute+'='+login+','+::Devise.ldap_base_dn
9
+ def self.valid_credentials?(login, attributes, password)
10
+ login = "#{::Devise.ldap_login_attribute}=#{login},"
11
+ login += "#{attributes}," unless attributes.nil?
12
+ login += ::Devise.ldap_base_dn
11
13
  @encryption = ::Devise.ldap_ssl ? :simple_tls : nil
12
14
  ldap = Net::LDAP.new(:encryption => @encryption)
13
15
  ldap.host = ::Devise.ldap_host
@@ -16,7 +18,6 @@ module Devise
16
18
  if ldap.bind
17
19
  true
18
20
  else
19
- # errors.add_to_base(ldap.get_operation_result.message)
20
21
  false
21
22
  end
22
23
  end
@@ -25,7 +25,7 @@ module Devise
25
25
 
26
26
  # Checks if a resource is valid upon authentication.
27
27
  def valid_ldap_authentication?(password)
28
- Devise::LdapAdapter.valid_credentials?(self.login, password)
28
+ Devise::LdapAdapter.valid_credentials?(self.login, self.ldap_attributes, password)
29
29
  end
30
30
 
31
31
  module ClassMethods
@@ -6,7 +6,8 @@ Devise::Schema.class_eval do
6
6
  def ldap_authenticatable(options={})
7
7
  null = options[:null] || false
8
8
 
9
- apply_schema :login, String, :null => null
9
+ apply_schema :login, String, :null => false
10
+ apply_schema :ldap_attributes, String, :null => true
10
11
  end
11
12
 
12
13
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_ldap_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 3
9
- version: 0.1.3
9
+ - 6
10
+ version: 0.1.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Curtis Schiewek
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-25 00:00:00 -04:00
18
+ date: 2010-07-22 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: devise
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">"
26
28
  - !ruby/object:Gem::Version
29
+ hash: 31
27
30
  segments:
28
31
  - 1
29
32
  - 0
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: net-ldap
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 31
41
46
  segments:
42
47
  - 0
43
48
  - 0
@@ -58,6 +63,7 @@ files:
58
63
  - README.md
59
64
  - Rakefile
60
65
  - VERSION
66
+ - devise_ldap_authenticatable.gemspec
61
67
  - lib/devise_ldap_authenticatable.rb
62
68
  - lib/devise_ldap_authenticatable/ldap_adapter.rb
63
69
  - lib/devise_ldap_authenticatable/model.rb
@@ -77,23 +83,27 @@ rdoc_options:
77
83
  require_paths:
78
84
  - lib
79
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
80
87
  requirements:
81
88
  - - ">="
82
89
  - !ruby/object:Gem::Version
90
+ hash: 3
83
91
  segments:
84
92
  - 0
85
93
  version: "0"
86
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
87
96
  requirements:
88
97
  - - ">="
89
98
  - !ruby/object:Gem::Version
99
+ hash: 3
90
100
  segments:
91
101
  - 0
92
102
  version: "0"
93
103
  requirements: []
94
104
 
95
105
  rubyforge_project:
96
- rubygems_version: 1.3.6
106
+ rubygems_version: 1.3.7
97
107
  signing_key:
98
108
  specification_version: 3
99
109
  summary: LDAP authentication module for Devise