Patch #21137 ยป 0001-Rescue-network-level-errors-with-LDAP-auth-to-avoid-.patch
| app/models/auth_source_ldap.rb | ||
|---|---|---|
| 20 | 20 |
require 'timeout' |
| 21 | 21 | |
| 22 | 22 |
class AuthSourceLdap < AuthSource |
| 23 |
NETWORK_EXCEPTIONS = [ |
|
| 24 |
Net::LDAP::LdapError, |
|
| 25 |
Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, |
|
| 26 |
Errno::EHOSTDOWN, Errno::EHOSTUNREACH, |
|
| 27 |
SocketError |
|
| 28 |
] |
|
| 29 | ||
| 23 | 30 |
validates_presence_of :host, :port, :attr_login |
| 24 | 31 |
validates_length_of :name, :host, :maximum => 60, :allow_nil => true |
| 25 | 32 |
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_blank => true |
| ... | ... | |
| 45 | 52 |
return attrs.except(:dn) |
| 46 | 53 |
end |
| 47 | 54 |
end |
| 48 |
rescue Net::LDAP::LdapError => e
|
|
| 55 |
rescue *NETWORK_EXCEPTIONS => e
|
|
| 49 | 56 |
raise AuthSourceException.new(e.message) |
| 50 | 57 |
end |
| 51 | 58 | |
| ... | ... | |
| 55 | 62 |
ldap_con = initialize_ldap_con(self.account, self.account_password) |
| 56 | 63 |
ldap_con.open { }
|
| 57 | 64 |
end |
| 58 |
rescue Net::LDAP::LdapError => e
|
|
| 65 |
rescue *NETWORK_EXCEPTIONS => e
|
|
| 59 | 66 |
raise AuthSourceException.new(e.message) |
| 60 | 67 |
end |
| 61 | 68 | |
| ... | ... | |
| 85 | 92 |
results << attrs |
| 86 | 93 |
end |
| 87 | 94 |
results |
| 88 |
rescue Net::LDAP::LdapError => e
|
|
| 95 |
rescue *NETWORK_EXCEPTIONS => e
|
|
| 89 | 96 |
raise AuthSourceException.new(e.message) |
| 90 | 97 |
end |
| 91 | 98 | |