sishen / omniauth-google-apps

OmniAuth strategy for Google Apps.
http://github.com/sishen/omniauth-google-apps
43 stars 17 forks source link

"undefined method `uses_extension' for ..." #11

Open beseku opened 10 years ago

beseku commented 10 years ago

When the Rails application receives the callback the above error is generated. No idea why.

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_apps, domain: 'http://domain.com'  
end
robinson-spai commented 10 years ago

Try removing the http://

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_apps, domain: 'domain.com'  
end
ttdonovan commented 10 years ago

I am experiencing the same issue with one of my applications.

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_apps, domain: 'domain.com'
end

undefined method `uses_extension' for #String:0x007fa5f3cf6d18

block in verify_discovery_singleruby-openid (2.3.0) lib/openid/consumer/idres.rb line 464

if !endpoint.uses_extension(type_uri)

endpoint is a string.

>> endpoint
=> "<OpenID::OpenIDServiceEndpoint server_url=https://www.google.com/a/domain.com/o8/ud?be=o8 claimed_id= local_id= canonical_id= used_yadis=true>"
>> endpoint.class
=> String

Here is a list of possibly relevant gems.

Any suggestions to troubleshoot this would greatly be appreciated.

ttdonovan commented 10 years ago

After some digging into ruby-openid it appears that the issues is with the OpenID::Consumer class with setting and getting of values from the ActionDispatch::Request::Session. The method last_requested_endpoint is returning the a string value of the Ruby object instead of the actual object.

At this point I'm not sure is this is an ActionDispatch or OpenID issue.

ttdonovan commented 10 years ago

The issues appears to be with Rails 4.1 and OpenID, see this issue thread for a possible resolution https://github.com/openid/ruby-openid/issues/75.

Rails.application.config.action_dispatch.cookies_serializer = :marshal
sishen commented 10 years ago

@ttdonovan Thank you for the info. Can you attach your whole Gemfile.lock, I'll take a dig. Thank you.

ttdonovan commented 10 years ago

@sishen I've included a link to a copy of my Gemfile.lock.

https://gist.github.com/ttdonovan/eee3d83468fad2018130#file-gemfile-lock

I feel the issue resides in the ruby-openid gem with Rails 4. Even in the upgrade Rails guide there is a call out about serializing objects in the session.

When using the :json or :hybrid serializer, you should beware that not all Ruby objects can be serialized as JSON. For example, Date and Time objects will be serialized as strings, and Hashes will have their keys stringified.

http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#cookies-serializer