未分類 | 10月 6th, 2008
デフォルトで用意されている Basic 認証の仕組みの使い方。ユーザ名 chihaya , パスワード password72 とすると、以下のようにする。
class ApplicationController < ActionController::Base before_filter :basic_authentication # テストだけ使うBasic認証 protected def basic_authentication authenticate_or_request_with_http_basic do |user, pass| [user, pass] == ['chihaya', 'password72'] end end end
特定のActionはBasic認証かけたくないならば、skip_before_filter を使う。
class NanohaController < ApplicationController skip_before_filter :basic_authentication, :only => [:show] def show end end





とおりすがり
2月 23rd, 2009グッジョブ!
GarykPatton
6月 17th, 2009I have been looking looking around for this kind of information. Will you post some more in future? I’ll be grateful if you will.
ちゅう
6月 18th, 2009Yes, I will post related to this post !
Please check my weblog. Thank you.