railsでのHTTP authentication
app/controllers/application_controller.rbに次のようにhttp_basic_authenticate_withを追加すればOK
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
http_basic_authenticate_with name: "sato", password: "pass" #これを追加
end
こんな感じでURLでアクセス得きるので便利!
http://sato:pass@localhost:3000/