adauth 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/adauth.rb +1 -0
- data/lib/adauth/connection.rb +10 -4
- data/lib/adauth/group.rb +1 -1
- data/lib/adauth/user.rb +1 -1
- data/lib/adauth/user_model.rb +5 -5
- data/lib/adauth/version.rb +1 -1
- data/spec/adauth_user_spec.rb +14 -0
- metadata +4 -4
data/lib/adauth.rb
CHANGED
data/lib/adauth/connection.rb
CHANGED
@@ -21,10 +21,16 @@ module Adauth
|
|
21
21
|
:auth => { :username => "#{login}@#{Adauth.config.domain}",
|
22
22
|
:password => pass,
|
23
23
|
:method => :simple }
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
begin
|
25
|
+
Timeout::timeout(10){
|
26
|
+
if conn.bind
|
27
|
+
return conn
|
28
|
+
else
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
}
|
32
|
+
rescue Timeout::Error
|
33
|
+
raise "Unable to connect to LDAP Server"
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/lib/adauth/group.rb
CHANGED
@@ -42,7 +42,7 @@ module Adauth
|
|
42
42
|
#
|
43
43
|
# Returns an array of Adauth::Users for the group
|
44
44
|
def members
|
45
|
-
filters = Net::LDAP::Filter.
|
45
|
+
filters = Net::LDAP::Filter.eq("memberof","CN=#{name},#{dn}")
|
46
46
|
members_ldap = @conn.search(:filter => filters)
|
47
47
|
members = []
|
48
48
|
members_ldap.each do |member|
|
data/lib/adauth/user.rb
CHANGED
data/lib/adauth/user_model.rb
CHANGED
@@ -36,7 +36,7 @@ module Adauth
|
|
36
36
|
# This method is called on login and shouldn't need to be called at any other time
|
37
37
|
def update_from_adauth(adauth_user)
|
38
38
|
self.group_strings = adauth_user.groups.join(", ")
|
39
|
-
self.name = adauth_user.name
|
39
|
+
self.name = adauth_user.name.gsub(/\"|\[|\]/, "")
|
40
40
|
self.save
|
41
41
|
end
|
42
42
|
|
@@ -52,7 +52,7 @@ module Adauth
|
|
52
52
|
#
|
53
53
|
# If the user has no user record in the database one will be created. All the details on the record (new and old) will be updated to the lastest details from the AD server
|
54
54
|
def return_and_create_with_adauth(adauth_user)
|
55
|
-
user = (find_by_login(adauth_user.login) || create_user_with_adauth(adauth_user))
|
55
|
+
user = (find_by_login(adauth_user.login.gsub(/\"|\[|\]/, "")) || create_user_with_adauth(adauth_user))
|
56
56
|
user.update_from_adauth(adauth_user)
|
57
57
|
return user
|
58
58
|
end
|
@@ -65,12 +65,12 @@ module Adauth
|
|
65
65
|
# Takes the Adauth::User input and creates a user record with matching details
|
66
66
|
def create_user_with_adauth(adauth_user)
|
67
67
|
create! do |user|
|
68
|
-
user.login = adauth_user.login
|
68
|
+
user.login = adauth_user.login.gsub(/\"|\[|\]/, "")
|
69
69
|
user.group_strings = adauth_user.groups.join(", ")
|
70
70
|
user.ou_strings = adauth_user.ous.join(", ")
|
71
|
-
user.name = adauth_user.name
|
71
|
+
user.name = adauth_user.name.gsub(/\"|\[|\]/, "")
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
end
|
76
|
+
end
|
data/lib/adauth/version.rb
CHANGED
data/spec/adauth_user_spec.rb
CHANGED
@@ -196,4 +196,18 @@ describe Adauth, "passwordless_login" do
|
|
196
196
|
it "should be a viable user when passwordless login is used" do
|
197
197
|
Adauth.passwordless_login(@yaml["user"]["login"]).login.should eq(@yaml["user"]["login"])
|
198
198
|
end
|
199
|
+
|
200
|
+
it "should raise an exception on timeout" do
|
201
|
+
Adauth.configure do |c|
|
202
|
+
c.domain = @yaml["domain"]["domain"]
|
203
|
+
c.server = "127.0.0.2"
|
204
|
+
c.port = @yaml["domain"]["port"]
|
205
|
+
c.base = @yaml["domain"]["base"]
|
206
|
+
c.admin_user = @yaml["domain"]["admin_user"]
|
207
|
+
c.admin_password = @yaml["domain"]["admin_password"]
|
208
|
+
end
|
209
|
+
|
210
|
+
lambda { Adauth::AdminConnection.bind }.should raise_error
|
211
|
+
|
212
|
+
end
|
199
213
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam "Arcath" Laycock
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-30 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|