Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Application_user = Settings[:authentication][:user]
- Application_pass = Settings[:authentication][:password]
- def protected! username = Application_user, password = Application_pass
- unless authorized? username, password
- response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth")
- throw(:halt, [401, "Not authorized\n"])
- end
- end
- def authorized? username, password
- username = Settings
- @auth ||= Rack::Auth::Basic::Request.new(request.env)
- @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [username, password]
- end
Add Comment
Please, Sign In to add comment