プロジェクト

全般

プロフィール

Vote #76246

未完了

LDAP authentication exception handling

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
LDAP_28
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
28
version_id:
0
issue_org_id:
19520
author_id:
12557
assigned_to_id:
0
comments:
2
status_id:
1
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

In case of problems with a domain controler used for LDAP authentication Errno::ECONNRESET exception might be thrown. However, only AuthSourceException is caugth in the account controller. Therefore an Internal error is displayed to users after their logn attempt. I'd recomend either adding another exception handling or changing to a general exception as in the attached patch.

Errno::ECONNRESET (Connection reset by peer):
  app/models/auth_source_ldap.rb:178:in `get_user_dn'
  app/models/auth_source_ldap.rb:42:in `block in authenticate'
  app/models/auth_source_ldap.rb:98:in `block in with_timeout'
  app/models/auth_source_ldap.rb:97:in `with_timeout'
  app/models/auth_source_ldap.rb:41:in `authenticate'
  app/models/user.rb:271:in `check_password?'
  app/controllers/account_controller.rb:186:in `authenticate_user'
  app/controllers/account_controller.rb:40:in `login'

journals

I don't like catching all exception in controller.
I think it is better catching in model.

<pre><code class="diff">
diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb
--- a/app/models/auth_source.rb
+++ b/app/models/auth_source.rb
@@ -18,6 +18,7 @@
# Generic exception for when the AuthSource can not be reached
# (eg. can not connect to the LDAP)
class AuthSourceException < Exception; end
+class AuthSourceConnectResetException < AuthSourceException; end
class AuthSourceTimeoutException < AuthSourceException; end

class AuthSource < ActiveRecord::Base
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -97,6 +97,8 @@ class AuthSourceLdap < AuthSource
Timeout.timeout(timeout) do
return yield
end
+ rescue Errno::ECONNRESET => e
+ raise AuthSourceConnectResetException.new(e.message)
rescue Timeout::Error => e
raise AuthSourceTimeoutException.new(e.message)
end

</code></pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリLDAP_28 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0