Sha256: d5d09cd3d4b9ccc2aeccf5432b1233148226ea062c722f05c919fe79432f93b3
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# ApplicationController just checks every incoming request according to the remote IP address. # # The request is sent to DocumentsController only if the IP is included in the white list. # Otherwise, it returns "Access denied" 403. class ApplicationController < ActionController::Base session :disabled => true before_filter :should_only_be_available_for_white_list_IPs, :except=> :access_denied # Returns 403 status in case of an unknown remote IP address def access_denied render :text=>request.inspect, :status => 403 end # Redirects to documents_url in case route hasn't been recognised def unknown_request flash[:warning]="Unknown URL" redirect_to documents_url end private # Tries to match remote IP address with the white list defined in config/custom/white_list_ip.yml # Redirects to :access_denied if the remote IP is not white listed. def should_only_be_available_for_white_list_IPs unless request.remote_ip =~ WhiteListIPs redirect_to :controller => 'application', :action=>'access_denied' return false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
picolena-0.1.1 | lib/picolena/templates/app/controllers/application.rb |