I'm porting my OpenId authentication scheme from Sinatra to Rails 2.3.8.
Everything works well up until I get the response back from my OpenId provider. The Response
object I get back is an OpenId::Consumer::FailureResponse
, when it should be a SuccessResponse
.
I ported this directly from Sinatra, and the only difference is what session object I'm using. (Rails session now vs. Rack session with Sinatra.) I know that things are working on the Provider end (not under my control).
The offending code looks something like this:
# POST /login/openid
def begin_login
openid = URI.parse(params[:openid]).to_s
begin
request = openid_consumer.begin(openid)
rescue OpenID::DiscoveryFailure => message
"Sorry, we couldn't find your identifier '#{openid}'"
else
# root_url and complete_login_url are defined in my routes file
# and the latter points to the next method: complete_login
redirect_to request.redirect_url(root_url, complete_login_url)
end
end
# POST /login/openid/complete
def complete_login
openid_consumer ||= OpenID::Consumer.new(session,
OpenID::Store::Filesystem.new("#{RAILS_ROOT}/tmp/openid"))
response = openid_consumer.complete(params, request.url)
response.class # => OpenID::Consumer::FailureResponse
end