tamacyaのブック
mindia › tamacyaのブック › 単語

rails BASIC認証

tamasally · 2012-04-28 更新 · 履歴(1)

authenticate_or_request_with_http_basicを使う。
すごく簡単だった。

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
before_filter :authenticate

private
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == 'ユーザー名' && password == 'パスワード'
end
end
end

タグ