Authlogic OpenID集成

时间:2010-05-19 16:05:56

标签: ruby-on-rails openid authlogic

我在使用Authlogic进行OpenId身份验证时遇到了困难。似乎问题出现在open_id_authentication插件的更改中。从我到目前为止所读到的,人们需要从使用宝石切换到使用插件。

到目前为止,我所做的是让Authlogic-OpenID集成工作:

  1. 删除了相关的宝石:
    • authlogic
    • authlogic - 旧
    • 机架的OpenID
    • ruby​​-openid *
    • 按预期安装,配置并启动了authlogic示例应用程序http://github.com/binarylogic/authlogic_example)--works。这需要:
    • 安装authlogic(2.1.3)gem($ sudo gem install authlogic)
    • 将一个依赖项(config.gem“authlogic”)添加到environment.rb文件中。
    • 添加了迁移功能,为用户模型添加了open-id支持;跑迁;列按预期添加
    • 对UsersController和UserSessionsController进行了更改,以使用块来保存每个。
    • 更改了新的用户会话视图以支持开放ID(f.text_field:openid_identifier)
    • 安装open_id_authentication插件($ script / plugin install git://github.com/rails/open_id_authentication.git)
    • 安装了authlogic-oid插件($ script / plugin install git://github.com/binarylogic/authlogic_openid.git)
    • 安装了插件($ script / plugin install git://github.com/glebm/ruby-openid.git)
    • 重启mongrel(CTRL-C; $ script / server)
  2. Mogrel未能启动,返回以下错误:

    /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
    

    我怀疑这与rack-openid宝石有关,但由于它依赖于ruby-openid宝石,所以当去掉ruby-openid宝石时它会被移除。也许这可以作为插件安装。

    非常感谢对此事的任何帮助 - 我即将放弃OpenId集成。

    * ruby​​-openid(2.1.2)安装在/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8。我不确定这是否会影响任何事情。在任何情况下,我都不确定如何卸载它或我是否应该。

    **编辑**

    似乎/Library/Ruby/Gems/1.8/gems目录中有许多宝石可能导致问题:

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

    问题:   - 为什么gem list命令没有列出这些宝石?   - 为什么gem uninstall命令没有删除这些宝石?

3 个答案:

答案 0 :(得分:3)

我刚刚遇到同样的问题,但修复了安装机架openid宝石的问题。 我会要求他们在文档

上添加rack-openid到所需的库

答案 1 :(得分:3)

我和你一样经历过同样的麻烦。 也许你应该检查一下,让一切正常:

http://github.com/shripadk/authlogic_openid_selector_example

这包括像openid自动注册一样的stackoverflow。我已经在heroku上托管了一个示例应用程序,如果你愿意,可以在结帐前试用。

答案 2 :(得分:0)

不确定OSX上的工作原理,但在Linux中,如果我将gems作为普通用户安装,则会将其放入我的主目录,如果我使用sudo安装它们,则会进入系统目录。

我也遇到了gems的权限问题,并且必须在我的shell中明确设置GEM_PATH以使ruby从特定位置加载gem。

  • 如果您运行sudo gem list
  • ,是否会显示这些旧宝石?
  • 您是否在主目录以及/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  • 中安装了宝石

修改

好的,我会启动一个irb会话,看看明确require宝石时会发生什么。

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

修改

如果安装了authlogic-oid gem,并在运行sudo gem list时显示,请尝试以超级用户身份启动irb。如果您可以要求authlogic-oid,则存在权限问题:部分或全部gem文件只读root。

如果这不起作用,您可能会遇到负载路径问题 - ruby​​对于在哪里查找已安装的宝石感到困惑。在这种情况下,您的authlogic gem可能安装在authlogic-oid gem的不同位置。