api: make IP addresses in the API.

Make the following fields visible in API responses:

* ip_bans.ip_addr
* ip_geolocations.ip_addr
* ip_geolocations.network
* users.last_ip_addr (mod only)
* user_sessions.ip_addr
* api_keys.last_ip_address
* api_keys.permitted_ip_addresses

Before IP addresses were globally hidden in API responses because IPs were
present in a lot of tables and we didn't want to accidentally leak them.
Now that we've gotten rid of IPs from most tables, it's safe to unhide them.
This commit is contained in:
evazion
2022-09-24 00:09:36 -05:00
parent 7bf824f0dd
commit adba70a0de
9 changed files with 34 additions and 32 deletions

View File

@@ -4,14 +4,14 @@ class IpBanTest < ActiveSupport::TestCase
should "be able to ban a user" do
ip_ban = create(:ip_ban, ip_addr: "1.2.3.4")
assert_equal("1.2.3.4", ip_ban.subnetted_ip)
assert_equal("1.2.3.4", ip_ban.ip_addr.to_s)
assert(IpBan.ip_matches("1.2.3.4").exists?)
end
should "be able to ban a subnet" do
ip_ban = create(:ip_ban, ip_addr: "1.2.3.4/24")
assert_equal("1.2.3.0/24", ip_ban.subnetted_ip)
assert_equal("1.2.3.0/24", ip_ban.ip_addr.to_s)
assert(IpBan.ip_matches("1.2.3.0").exists?)
assert(IpBan.ip_matches("1.2.3.255").exists?)
end