Guest User

Untitled

a guest
Apr 13th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. # Basic auth with name, pass and ip region
  2. require "ipaddr"
  3.  
  4. def login_from_basic_auth
  5. net = IPAddr.new(AppConfig['admin_network']) # something like 201.62.0.0/16
  6. authenticate_with_http_basic do |username, password|
  7. username == AppConfig['admin_user'] &&
  8. password == AppConfig['admin_password'] &&
  9. net.include?(IPAddr.new(request.remote_ip))
  10. end
  11. end
Add Comment
Please, Sign In to add comment