iPhoneアプリに接続するアプリがあり、それがhttp_digestを介してユーザーを認証します。
私は authlogic を使用しています。私のスキーマでは、Web サイトのユーザーは「ユーザー」であり、電話アプリのユーザーは「人」です。だから、私は user_sessions と people_sessions を持っています。http_digest 認証を処理するために、次のような authenticate_or_request_with_http_digest メソッドを使用しています。
def digest_authenticate_person
authenticate_or_request_with_http_digest do |email, password|
#ldb is just a logging method i have
ldb "email = #{email.inspect}, password = #{password.inspect}"
person = Person.find_by_email(email)
if person
ldb "Authentication successful: Got person with id #{person.id}"
@current_person_session = PersonSession.create(person)
else
ldb "Authentication failed"
@current_person_session = nil
end
return @current_person_session
end
end
パスワードが nil であることをログで確認できます。メールのみが authenticate_or_request_with_http_digest ブロックの内部に渡されます。
次のようなcurl呼び出しでこれをテストしています:
curl --digest --user fakename@madeup.xyz:apass "http://localhost:3000/reports.xml"
「fakename@madeup.xyz」と「apass」がブロックの内部に渡されることを期待しています。パスワードを取得したら、電子メールとパスワードの組み合わせを使用して、通常の方法でユーザーを検索 (または検索しない) できます。パスワードにアクセスする方法を知っている人はいますか?
アドバイスに感謝します - マックス
編集 - さらにグーグルで調べてみると、この方法を間違って使用していると思います。パスワードまたは暗号化されたパスワードを返すだけです。しかし、それを http_digest ユーザー名の一部として渡されたパスワードと比較するにはどうすればよいでしょうか?