production環境のみダイジェスト認証を有効にする
class ApplicationController < ActionController::Base USERS = { 'naoty' => 'coolguy' } protect_from_forgery before_filter { digest_authentication if Rails.env.production? } private def digest_authentication authenticate_or_request_with_http_digest do |name| USERS[name] end end end
ポイントは3つ。