OpenId Authentication Pluginのサンプルにはまった。
最近RailsのOpenIdAuthentication Pluginに挑戦しています。
open_id_authenticationプラグインの導入はこちらを参考にしました。
open_id_authentication*[認証][Rails] open_id_authenticationをつかってみる - KazusaAPI開発日誌 - KDRIグループ
koress.jp: 解消法: open_id_authenticationプラグイン(rails 2.0.2)
サンプルを動かしてみてOpenID Profider(IdP)からリダイレクトされてくるところまではスムーズに行ったのですが、その後のレスポンスを解析する部分で、このプラグインに添付してあるサンプルソースに潜んだバグ(?)にはまりました。
具体的にハマったのは、サンプルソース内の以下の部分で使われているcase .. when構文の比較ルール。
-
authenticate_with_open_id do |result, identity_url|
-
case result
-
when :missing
-
failed_login "Sorry, the OpenID server couldn't be found"
-
when :canceled
-
failed_login "OpenID verification was canceled"
-
when :failed
-
failed_login "Sorry, the OpenID verification failed"
-
when :successful
-
if @current_user = @account.users.find_by_identity_url(identity_url)
-
successful_login
-
else
-
failed_login "Sorry, no user by that identity URL exists (#{identity_url})"
-
end
-
end
-
end
ここでは以下のような評価を想定されているようです。











