summaryrefslogtreecommitdiffstats
path: root/app/models/auth_source_ldap.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-11-07 08:27:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-11-07 08:27:27 +0000
commit8123006bb3a43c3dd1cab8f849c51b79362c6b3a (patch)
tree2b244430e76bd21641b9cd42cab332f16964897d /app/models/auth_source_ldap.rb
parent269ba694b58664a4d2a88caba3a082c74c16ec25 (diff)
downloadredmine-8123006bb3a43c3dd1cab8f849c51b79362c6b3a.tar.gz
redmine-8123006bb3a43c3dd1cab8f849c51b79362c6b3a.zip
Rescue network level errors with LDAP auth (#21137).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@14808 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/auth_source_ldap.rb')
-rw-r--r--app/models/auth_source_ldap.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index 6fb43d44a..d5a8550c7 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -20,6 +20,13 @@ require 'net/ldap/dn'
require 'timeout'
class AuthSourceLdap < AuthSource
+ NETWORK_EXCEPTIONS = [
+ Net::LDAP::LdapError,
+ Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET,
+ Errno::EHOSTDOWN, Errno::EHOSTUNREACH,
+ SocketError
+ ]
+
validates_presence_of :host, :port, :attr_login
validates_length_of :name, :host, :maximum => 60, :allow_nil => true
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_blank => true
@@ -45,7 +52,7 @@ class AuthSourceLdap < AuthSource
return attrs.except(:dn)
end
end
- rescue Net::LDAP::LdapError => e
+ rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end
@@ -55,7 +62,7 @@ class AuthSourceLdap < AuthSource
ldap_con = initialize_ldap_con(self.account, self.account_password)
ldap_con.open { }
end
- rescue Net::LDAP::LdapError => e
+ rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end
@@ -85,7 +92,7 @@ class AuthSourceLdap < AuthSource
results << attrs
end
results
- rescue Net::LDAP::LdapError => e
+ rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end