casino-ldap_authenticator 2.0.0.pre.1 → 2.0.0
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.
- data/.travis.yml +5 -0
- data/README.md +1 -1
- data/casino-ldap_authenticator.gemspec +2 -1
- data/lib/casino/ldap_authenticator.rb +5 -2
- data/lib/casino/ldap_authenticator/version.rb +1 -1
- data/spec/casino/ldap_authenticator_spec.rb +46 -3
- data/spec/spec_helper.rb +2 -0
- metadata +24 -7
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# casino-ldap_authenticator [](https://travis-ci.org/rbCAS/casino-ldap_authenticator)
|
1
|
+
# casino-ldap_authenticator [](https://travis-ci.org/rbCAS/casino-ldap_authenticator) [](https://coveralls.io/r/rbCAS/casino-ldap_authenticator)
|
2
2
|
|
3
3
|
Provides mechanism to use LDAP as an authenticator for [CASino](https://github.com/rbCAS/CASino).
|
4
4
|
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency 'rake', '~> 10.0'
|
21
21
|
s.add_development_dependency 'rspec', '~> 2.12'
|
22
22
|
s.add_development_dependency 'simplecov', '~> 0.7'
|
23
|
+
s.add_development_dependency 'coveralls'
|
23
24
|
|
24
25
|
s.add_runtime_dependency 'net-ldap', '~> 0.3'
|
25
|
-
s.add_runtime_dependency 'casino', '~> 3.0.0
|
26
|
+
s.add_runtime_dependency 'casino', '~> 3.0.0'
|
26
27
|
end
|
@@ -42,8 +42,11 @@ class CASino::LDAPAuthenticator
|
|
42
42
|
@ldap.auth(@options[:admin_user], @options[:admin_password])
|
43
43
|
end
|
44
44
|
@user_plain = @ldap.bind_as(:base => @options[:base], :size => 1, :password => @password, :filter => user_filter)
|
45
|
-
if @user_plain
|
46
|
-
@user_plain = @
|
45
|
+
if @user_plain != false
|
46
|
+
@user_plain = @ldap.search(:base => @options[:base], :filter => user_filter, :attributes => @options[:extra_attributes].values)
|
47
|
+
if @user_plain.is_a?(Array)
|
48
|
+
@user_plain = @user_plain.first
|
49
|
+
end
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
@@ -8,7 +8,7 @@ describe CASino::LDAPAuthenticator do
|
|
8
8
|
:base => 'dc=users,dc=example.com',
|
9
9
|
:encryption => 'simple_tls',
|
10
10
|
:username_attribute => 'uid',
|
11
|
-
:extra_attributes => { :email => 'mail', :fullname => :displayname }
|
11
|
+
:extra_attributes => { :email => 'mail', :fullname => :displayname, :memberof => 'memberof'}
|
12
12
|
} }
|
13
13
|
let(:subject) { described_class.new(options) }
|
14
14
|
let(:connection) { Object.new }
|
@@ -24,9 +24,11 @@ describe CASino::LDAPAuthenticator do
|
|
24
24
|
let(:username) { 'test' }
|
25
25
|
let(:password) { 'foo' }
|
26
26
|
let(:user_filter) { Net::LDAP::Filter.eq(options[:username_attribute], username) }
|
27
|
+
let(:extra_attributes) { ['mail', :displayname, 'memberof'] }
|
27
28
|
|
28
29
|
before(:each) do
|
29
30
|
connection.stub(:bind_as)
|
31
|
+
connection.stub(:search)
|
30
32
|
end
|
31
33
|
|
32
34
|
it 'does the connection setup' do
|
@@ -41,7 +43,12 @@ describe CASino::LDAPAuthenticator do
|
|
41
43
|
subject.validate(username, password)
|
42
44
|
end
|
43
45
|
|
44
|
-
|
46
|
+
it 'calls the #search method on the LDAP connection' do
|
47
|
+
connection.should_receive(:search).with(:base => options[:base], :filter => user_filter, :attributes => extra_attributes)
|
48
|
+
subject.validate(username, password)
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when validation succeeds for user with missing data' do
|
45
52
|
let(:fullname) { 'Example User' }
|
46
53
|
let(:email) { "#{username}@example.org" }
|
47
54
|
let(:ldap_entry) {
|
@@ -55,6 +62,41 @@ describe CASino::LDAPAuthenticator do
|
|
55
62
|
connection.stub(:bind_as) do
|
56
63
|
ldap_entry
|
57
64
|
end
|
65
|
+
connection.stub(:search) do
|
66
|
+
ldap_entry
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns the user data with blank value for missing data' do
|
71
|
+
subject.validate(username, password).should == {
|
72
|
+
username: username,
|
73
|
+
extra_attributes: {
|
74
|
+
:email => email,
|
75
|
+
:fullname => fullname,
|
76
|
+
:memberof => ''
|
77
|
+
}
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when validation succeeds for user with complete data' do
|
83
|
+
let(:fullname) { 'Example User' }
|
84
|
+
let(:email) { "#{username}@example.org" }
|
85
|
+
let(:membership) { "cn=group1" }
|
86
|
+
let(:ldap_entry) {
|
87
|
+
entry = Net::LDAP::Entry.new
|
88
|
+
{:uid => username, :displayname => fullname, :mail => email, :memberof => membership}.each do |key, value|
|
89
|
+
entry[key] = [value]
|
90
|
+
end
|
91
|
+
entry
|
92
|
+
}
|
93
|
+
before(:each) do
|
94
|
+
connection.stub(:bind_as) do
|
95
|
+
ldap_entry
|
96
|
+
end
|
97
|
+
connection.stub(:search) do
|
98
|
+
ldap_entry
|
99
|
+
end
|
58
100
|
end
|
59
101
|
|
60
102
|
it 'returns the user data' do
|
@@ -62,7 +104,8 @@ describe CASino::LDAPAuthenticator do
|
|
62
104
|
username: username,
|
63
105
|
extra_attributes: {
|
64
106
|
:email => email,
|
65
|
-
:fullname => fullname
|
107
|
+
:fullname => fullname,
|
108
|
+
:memberof => membership
|
66
109
|
}
|
67
110
|
}
|
68
111
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casino-ldap_authenticator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nils Caspar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.7'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: coveralls
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: net-ldap
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +98,7 @@ dependencies:
|
|
82
98
|
requirements:
|
83
99
|
- - ~>
|
84
100
|
- !ruby/object:Gem::Version
|
85
|
-
version: 3.0.0
|
101
|
+
version: 3.0.0
|
86
102
|
type: :runtime
|
87
103
|
prerelease: false
|
88
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +106,7 @@ dependencies:
|
|
90
106
|
requirements:
|
91
107
|
- - ~>
|
92
108
|
- !ruby/object:Gem::Version
|
93
|
-
version: 3.0.0
|
109
|
+
version: 3.0.0
|
94
110
|
description: This gem can be used to allow the CASino backend to authenticate against
|
95
111
|
an LDAP server.
|
96
112
|
email:
|
@@ -104,6 +120,7 @@ files:
|
|
104
120
|
- .rspec
|
105
121
|
- .ruby-gemset
|
106
122
|
- .ruby-version
|
123
|
+
- .travis.yml
|
107
124
|
- Gemfile
|
108
125
|
- LICENSE.txt
|
109
126
|
- README.md
|
@@ -130,9 +147,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
148
|
none: false
|
132
149
|
requirements:
|
133
|
-
- - ! '
|
150
|
+
- - ! '>='
|
134
151
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
152
|
+
version: '0'
|
136
153
|
requirements: []
|
137
154
|
rubyforge_project:
|
138
155
|
rubygems_version: 1.8.23
|