Skip to content

Commit

Permalink
Merge pull request #217 from astockwell/feature/obscure_auth
Browse files Browse the repository at this point in the history
obscure auth password upon #inspect, added test, closes #216
  • Loading branch information
jch committed Sep 17, 2015
2 parents e7fde22 + 02ec36e commit 49c0265
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,13 @@ def paged_searches_supported?
@server_caps[:supportedcontrol].include?(Net::LDAP::LDAPControls::PAGED_RESULTS)
end

# Mask auth password
def inspect
inspected = super
inspected.gsub! @auth[:password], "*******" if @auth[:password]
inspected
end

private

# Yields an open connection if there is one, otherwise establishes a new
Expand Down
7 changes: 7 additions & 0 deletions test/test_ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ def test_instrument_search_with_size
assert_equal "(uid=user1)", payload[:filter]
assert_equal result.size, payload[:size]
end

def test_obscure_auth
password = "opensesame"
assert_include(@subject.inspect, "anonymous")
@subject.auth "joe_user", password
assert_not_include(@subject.inspect, password)
end
end

0 comments on commit 49c0265

Please sign in to comment.