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 CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'net/ldap'
2
+ require 'timeout'
2
3
  require 'adauth/version'
3
4
  require 'adauth/user'
4
5
  require 'adauth/config'
@@ -21,10 +21,16 @@ module Adauth
21
21
  :auth => { :username => "#{login}@#{Adauth.config.domain}",
22
22
  :password => pass,
23
23
  :method => :simple }
24
- if conn.bind
25
- return conn
26
- else
27
- return nil
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.construct("(memberOf=#{dn})")
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
@@ -81,7 +81,7 @@ module Adauth
81
81
  define_method(k) do
82
82
  if @entry.attribute_names.include?(val)
83
83
  if block.is_a?(Proc)
84
- return block[@entry.send(val).to_s]
84
+ return block[@entry.send(val)]
85
85
  else
86
86
  return @entry.send(val).to_s
87
87
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Adauth
2
2
 
3
3
  # The version of the gem
4
- Version = "1.2.0"
4
+ Version = "1.2.1"
5
5
  end
@@ -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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
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: 2011-09-01 00:00:00 +01:00
18
+ date: 2012-01-30 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency