ruby - How to allow special IP or host access /admin page with Rails? -
if django, can use allowed_hosts = []
in settings.py
file.
how rails?
i think can try
def local_allow_ip_ranges %w{ 127.0.0.1 12.123.1.123 192.168.1.0/255.255.255.0 } end
now below method checks if given ip in above list
def is_local(ip) require 'ipaddr' ip = ipaddr.new(ip) local_allow_ip_ranges.any? {|range| ipaddr.new(range).include?(ip) } end
Comments
Post a Comment