Skip to content

Commit

Permalink
Fixes #17998 - Only print LDAP bind status if available
Browse files Browse the repository at this point in the history
The ldap logger tries to call payload[:bind].status but it might not be
defined if the bind goes wrong in some LDAP sources.

This causes a 500 instead of logging the status of the bind. We should
only display payload[:bind].status if it's available.
  • Loading branch information
dLobatog committed Jan 10, 2017
1 parent a4dccd9 commit 09a9a69
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/initializers/ldap_instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ def self.define_log(action, log_name, color)
end

class NetLdapSubscriber < LdapSubscriber
define_log(:bind, 'op bind', YELLOW) { |payload| "result=#{payload[:bind].status}" }
define_log(:bind, 'op bind', YELLOW) do |payload|
if payload[:bind].try(:status)
"result=#{payload[:bind].status}"
else
"result=#{payload[:bind]}"
end
end
define_log(:search, 'op search', YELLOW) { |payload| "filter=#{payload[:filter]}, base=#{payload[:base]}" }
end

Expand Down

0 comments on commit 09a9a69

Please sign in to comment.