Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Basic auth with name, pass and ip region
- require "ipaddr"
- def login_from_basic_auth
- net = IPAddr.new(AppConfig['admin_network']) # something like 201.62.0.0/16
- authenticate_with_http_basic do |username, password|
- username == AppConfig['admin_user'] &&
- password == AppConfig['admin_password'] &&
- net.include?(IPAddr.new(request.remote_ip))
- end
- end
Add Comment
Please, Sign In to add comment