views:

503

answers:

3

I'm having difficulty getting OpenId authentication working with Authlogic. It appears that the problem arose with changes to the open_id_authentication plugin. From what I've read so far, one needs to switch from using gems to using plugins.

Here's what I done thus far to get Authlogic-OpenID integration working:

  1. Removed relevant gems:
    • authlogic
    • authlogic-oid
    • rack-openid
    • ruby-openid *
    • Installed, configured, and started the authlogic sample application (http://github.com/binarylogic/authlogic_example)--works as expected. This required:
    • installing the authlogic (2.1.3) gem ($ sudo gem install authlogic)
    • adding a dependency (config.gem "authlogic") to the environment.rb file.
    • added migration to add open-id support to User model; ran migration; columns added as expected
    • made changes to the UsersController and UserSessionsController to use blocks to save each.
    • made changes to new user-sessions view to support open id (f.text_field :openid_identifier)
    • installed open_id_authentication plugin ($ script/plugin install git://github.com/rails/open_id_authentication.git)
    • installed the authlogic-oid plugin ($ script/plugin install git://github.com/binarylogic/authlogic_openid.git)
    • installed the plugin ($ script/plugin install git://github.com/glebm/ruby-openid.git)
    • restarted mongrel (CTRL-C; $ script/server)

Mogrel failed to start, returning the following error:

/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- rack/openid (MissingSourceFile)
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:3
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/plugins/open_id_authentication/init.rb:5:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:146:in `evaluate_init_rb'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:142:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:48:in `load'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:38:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:37:in `each'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:37:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:348:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:163:in `process'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
    from /Users/craibuc/NetBeansProjects/authlogic_example/config/environment.rb:13
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    from /Users/craibuc/NetBeansProjects/authlogic_example/vendor/rails/railties/lib/commands/server.rb:84
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from script/server:3

I suspect this is related the rack-openid gem, but as it was dependent upon the ruby-openid gem, it was removed when the ruby-openid gem was removed. Perhaps this can be installed as a plugin.

Any assistance with this matter is greatly appreciated--I'm just about to give up on OpenId integration.

* ruby-openid (2.1.2) is installed at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8. I'm not certain if this is affecting anything. In any case, I'm not sure how to uninstall it or if I should.

** edit **

It appears that there are a number of gems in the /Library/Ruby/Gems/1.8/gems directory that may be causing an issue:

  • authlogic-oid (1.0.4)
  • rack-openid (1.0.3)
  • ruby-openid (2.1.7)

Questions: - why doesn't the gem list command list these gems? - Why doesn't the gem uninstall command remove these gems?

A: 

Not sure how things work on OSX, but in Linux if I install gems as a regular user they get put in my home directory, and if I install them using sudo they go into a system directory.

I've had permissions problems with gems as well, and had to explicitly set a GEM_PATH in my shell to get ruby to load gems from a specific location.

  • Do those old gems show up if you run sudo gem list?
  • Do you have gems installed in your home directory as well as in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8?

Edit:

Ok, I'd fire up an irb session and see what happens when you require the gems explicitly.

$ irb
> require 'authlogic'
> require 'authlogic-oid'
...

Edit:

If the authlogic-oid gem is installed, and appears when you run sudo gem list, try starting irb as superuser. If you can then require authlogic-oid, you have a permissions problem: some or all of the gem files are readonly root.

If that doesn't work, you likely have a load path problem - ruby is confused about where to look for your installed gems. In that case, your authlogic gem is probably installed in a different location to your authlogic-oid gem.

nfm
sudo gem list does not enumerate these gems.I have gems installed in three locations: /Library/Ruby/Gems/1.8/gems, /craibuc/.gem/ruby/1.8/gems, and /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems.
Craig
Is uninstalling a gem as easy as deleting the gem's directory?
Craig
Yep, unless it's also installed executables elsewhere (as is the case with `rails` and `haml` for example)
nfm
To uninstall the gem, I decided to delete the directory, install the gem ($ sudo gem [gem name] install), then uninstall the gem ($ sudo gem [gem name] uninstall). This appears to have removed the gem 'properly'. I'll test the authlogic-openid integration tomorrow.
Craig
require 'authlogic' returned true. require 'authlogic-oid' returned: no such file to load -- authlogic-oid
Craig
Updated answer with more ideas
nfm
+3  A: 

i've got the same problem here just now, but fixed just installing the rack-openid gem. I'll ask them to add rack-openid to the required libraries on documentation

vrsmn
+1  A: 

I went through the same hassles as you did. Maybe you should just check this out, have got everything working:

http://github.com/shripadk/authlogic_openid_selector_example

This includes a stackoverflow like openid autoregistration too. I have hosted an example app on heroku for you to try out before checkout if you want to.

Shripad K