0
我在我的公共頁面中有一個窗體,我想鎖定到內部IP範圍。我一直在回顧其他問題的答案,但是他們將整個網站都包含在內,我希望能夠將其限制在少數幾頁。我的確發現在ApplicationController
Rails 4白名單IP到單一路由
before_filter :protect
def protect
@ips = ['127.0.0.1', '203.123.10.1'] #And so on ...]
if not @ips.include? request.remote_ip
# Check for your subnet stuff here, for example
# if not request.remote_ip.include?('127.0,0')
render :text => "You are unauthorized"
return
end
end
您試過使用這顆寶石嗎? –
我沒有,我會研究它。 – lostrennie
@lostrennie它看起來很棒/簡單的解決方案! –