mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
CC fixes
This commit is contained in:
parent
3943628716
commit
708e87f5a7
3 changed files with 5 additions and 12 deletions
|
@ -14,9 +14,7 @@ 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,7 @@ 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.include_ip?(ip)
|
||||
end
|
||||
|
||||
|
|
|
@ -40,17 +40,14 @@ class WhiteIp < ApplicationRecord
|
|||
|
||||
class << self
|
||||
# rubocop:disable Style/CaseEquality
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def include_ip?(ip)
|
||||
Rails.logger.info "Checking if whitelist includes ip: #{ip}"
|
||||
return false if ip.blank?
|
||||
|
||||
result = where(id: ids_including(ip)).any?
|
||||
Rails.logger.info "Result is: #{result}"
|
||||
result
|
||||
where(id: ids_including(ip)).any?
|
||||
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) }
|
||||
|
@ -58,11 +55,10 @@ class WhiteIp < ApplicationRecord
|
|||
if check_ip6(ip).present?
|
||||
ipv6 = select { |white_ip| IPAddr.new(white_ip.ipv6, Socket::AF_INET6) === check_ip6(ip) }
|
||||
end
|
||||
result = (ipv4 + ipv6).pluck(:id).flatten.uniq
|
||||
Rails.logger.info "Result is #{result}"
|
||||
result
|
||||
(ipv4 + ipv6).pluck(:id).flatten.uniq
|
||||
end
|
||||
# rubocop:enable Style/CaseEquality
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def check_ip4(ip)
|
||||
IPAddr.new(ip, Socket::AF_INET)
|
||||
|
@ -75,6 +71,5 @@ class WhiteIp < ApplicationRecord
|
|||
rescue StandardError => _e
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue