Skip to content

Instantly share code, notes, and snippets.

@geronimod
Created September 8, 2012 17:28
Show Gist options
  • Save geronimod/3677603 to your computer and use it in GitHub Desktop.
Save geronimod/3677603 to your computer and use it in GitHub Desktop.
Authorization by ip
# foo controller
AUTHORIZED_IPS = [127.0.0.1, ...]
before_filter :authorize_by_ip
def authorize_by_ip
redirect_to login_path, :warning => "access denied" unless AUTHORIZED_IPS.include? request.remote_ip
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment