mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 15:14:47 +02:00
Add some debug messages
This commit is contained in:
parent
f01e59d95a
commit
3943628716
3 changed files with 13 additions and 5 deletions
|
@ -14,7 +14,9 @@ module Authorization
|
|||
end
|
||||
|
||||
def can_access_registrar_area_sign_in_page?
|
||||
Rails.logger.info "Checking if Auth::RestrictedIp.enabled: #{self.class.enabled?}"
|
||||
return true unless self.class.enabled?
|
||||
Rails.logger.info "Checking if registrar area accessible, result: #{WhiteIp.registrar_area.include_ip?(ip)}"
|
||||
WhiteIp.registrar_area.include_ip?(ip)
|
||||
end
|
||||
|
||||
|
|
|
@ -137,7 +137,8 @@ class Registrar < ApplicationRecord
|
|||
|
||||
def api_ip_white?(ip)
|
||||
return true unless Setting.api_ip_whitelist_enabled
|
||||
white_ips.api.pluck(:ipv4, :ipv6).flatten.include?(ip)
|
||||
# white_ips.api.pluck(:ipv4, :ipv6).flatten.include?(ip)
|
||||
white_ips.api.include_ip?(ip)
|
||||
end
|
||||
|
||||
# Audit log is needed, therefore no raw SQL
|
||||
|
|
|
@ -41,21 +41,26 @@ class WhiteIp < ApplicationRecord
|
|||
class << self
|
||||
# rubocop:disable Style/CaseEquality
|
||||
def include_ip?(ip)
|
||||
Rails.logger.info "Checking if whitelist includes ip:#{ip}"
|
||||
Rails.logger.info "Checking if whitelist includes ip: #{ip}"
|
||||
return false if ip.blank?
|
||||
|
||||
where(id: ids_including(ip)).any?
|
||||
result = where(id: ids_including(ip)).any?
|
||||
Rails.logger.info "Result is: #{result}"
|
||||
result
|
||||
end
|
||||
|
||||
def ids_including(ip)
|
||||
Rails.logger.info "Checking ip #{ip}"
|
||||
ipv4 = ipv6 = []
|
||||
if check_ip4(ip).present?
|
||||
ipv4 = select { |white_ip| IPAddr.new(white_ip.ipv4, Socket::AF_INET) === check_ip4(ip) }
|
||||
end
|
||||
if check_ip6(ip).present?
|
||||
ipv6 = select { |white_ip| IPAddr.new(white_ip.ipv6, Socket::AF_INET6) === check_ip6 }
|
||||
ipv6 = select { |white_ip| IPAddr.new(white_ip.ipv6, Socket::AF_INET6) === check_ip6(ip) }
|
||||
end
|
||||
(ipv4 + ipv6).pluck(:id).flatten.uniq
|
||||
result = (ipv4 + ipv6).pluck(:id).flatten.uniq
|
||||
Rails.logger.info "Result is #{result}"
|
||||
result
|
||||
end
|
||||
# rubocop:enable Style/CaseEquality
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue