标签: authlogic

Ruby-OpenID:要求OpenID提供商提供电子邮件地址

我正在使用authlogic-example-app,当我注册用户时,我无法从OpenID提供商(在我的情况下是谷歌和雅虎)获得电子邮件地址.我得到一个空响应而不是电子邮件地址(请查看下面代码中的注释).

这就是我的用户模型的样子(其他一切看起来像上面提到的authlogic-example-app的"with_openid" - 分支).除了缺少"电子邮件"之外,openid-authentication-process按预期工作:

class User < ActiveRecord::Base
  acts_as_authentic do |c| 
    # not needed because I use OpenID
    c.validate_login_field = false
    # avoid failed validation before OpenID request
    c.validate_email_field = false
    # this one sets 'openid.sreg.required=email'
    c.required_fields = [:email]
  end

  private

  # overwriting the existing method in '/lib/authlogic_openid/acts_as_authentic.rb'
  def map_openid_registration(registration)
    # this is my problem: 'registration' is an empty hash
    self.email ||= registration[:email] if respond_to?(:email) && !registration[:email].blank?
  end

end
Run Code Online (Sandbox Code Playgroud)

不知道怎么解决这个问题?有没有人在使用authlogic之前完成此操作?甚至更好:你有一个有效的例子吗?

更新:我检查了Google帐户身份验证API,并将authlogic(使用 …

ruby openid ruby-on-rails ruby-openid authlogic

10
推荐指数
1
解决办法
3315
查看次数

RESTful-Authentication还是Authlogic?

我在两者之间做出决定时遇到了麻烦.它们看起来都很棒,但我想知道哪个更容易控制.

你的这些插件有什么经验?你会推荐哪个?

ruby authentication ruby-on-rails restful-authentication authlogic

10
推荐指数
1
解决办法
2305
查看次数

使用Authlogic进行集成测试?

对于我的生活,我不明白为什么Authlogic没有在这个集成测试中登录我.我没有遇到任何问题,Authlogic使用此代码在功能测试中登录我.根据authlogic rdocs(http://tinyurl.com/mb2fp2),模拟登录状态在功能和集成测试中是相同的,所以我很困惑.任何帮助深表感谢!

class TipsController < ApplicationController
  before_filter :require_user,  :only => [:destroy, :undelete]
  def destroy
    @tip = Tip.find(params[:id])

    if can_delete?(@tip)

      @tip.destroy

      set_flash("good", "Tip deleted. <a href=\"#{undelete_tip_url(@tip.id)}\">Undo?</a>")
      respond_to do |format|
        format.html { redirect_to city_path(@tip.city)} 
      end
    else
      set_flash("bad", "Seems like you can't delete this tip, sorry.")
      respond_to do |format|
        format.html { render :action => "show", :id => @tip} 
      end
    end
  end
end


class DeleteTipAndRender < ActionController::IntegrationTest
  context "log user in" do
    setup do
      @user = create_user
      @tip = create_tip
    end

    context …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails authlogic

10
推荐指数
1
解决办法
5268
查看次数

Authlogic openid,每个帐户有多个openid标识符

您将如何使用authlogic 允许用户使用多个 openid帐户和可选的密码登录?

ruby openid ruby-on-rails authlogic

10
推荐指数
1
解决办法
737
查看次数

Rails,OpenID和Authlogic

我一直在关注ryan baytes截屏#170并将ruby-openid,authlogicauthlogic-oid添加到现有的authlogic身份验证系统中.

但是,我不断收到以下一堆错误:

NameError(未初始化的常量OpenIdAuthentication :: InvalidOpenId):/ Library/Ruby/Gems/1.8/gems/openid_identifier=' /Library/Ruby/Gems/1.8/gems/authlogic-oid-1.0.4/lib/authlogic_openid/session.rb:47:inauthlogic- oid-1.0.4/lib/authlogic_openid/session:rb:53:in credentials ='authlogic(2.1.2)lib /authlogic/session/foundation.rb:28:in initialize' authlogic (2.1.2) lib/authlogic/session/password.rb:140:in初始化'authlogic(2.1.2)lib/authlogic/session/activation.rb:48:initialize' authlogic (2.1.2) lib/authlogic/session/klass.rb:61:in初始化'authlogic(2.1.2)lib/authlogic/session/scopes.rb :79:在initialize' app/controllers/user_sessions_controller.rb:10:in新的'app/controllers/user_sessions_controller.rb中:10:在'create'中

有没有人面临同样的问题?我正在使用rails 2.3.4

我已经尝试了二进制的示例应用程序,它运行得非常好(rails 2.1.2),我已经尝试了ryan bates提供的代码,它也运行良好(rails 2.3.2).因此,这些库正在使用以前版本的rails.

有线索吗?

authentication ruby-on-rails authlogic authlogic-oid railscasts

10
推荐指数
1
解决办法
1068
查看次数

Ruby on Rails:添加Facebook登录,Twitter登录,OpenID登录等的最佳方式

我目前正在运行Ruby on Rails应用程序,Authlogic处理我的身份验证和用户管理.

我正在努力寻找有关向我的网站添加第三方登录方法的最佳方式的最新信息,补充标准注册和登录.有很多教程,但似乎都过时或不完整.我可以获得一些关于向Authlogic添加多个第三方登录方法的最佳方法的建议吗?

Authlogic似乎是从头开始为这类事物构建的,但它的文档记录非常糟糕,并且它自己的页面似乎已经过时了.

他们似乎建议Facebook使用authlogic_facebook_connect插件,而插件依赖于过时的Facebooker宝石,后者已被Facebooker2取代.有没有办法将Facebooker2与Authlogic一起使用?

我还在Google上找到了authlogic_oauth2,这是一个更现代的插件,可以使用OAuth2使用Facebook凭据登录.不幸的是,作者声称由于冲突,此插件不能与OAuth(Twitter)和OpenID的Authlogic插件一起使用.

我可以一起使用哪些推荐的宝石或插件来允许通过Facebook,Twitter和OpenID登录我的网站?

ruby-on-rails authlogic

10
推荐指数
2
解决办法
1万
查看次数

Authlogic OpenID集成

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

以下是我为使Authlogic-OpenID集成工作所做的工作:

  1. 删除了相关的宝石:
    • authlogic
    • authlogic-OID
    • 机架的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文件中.
    • 添加迁移以向User模型添加open-id支持; 跑迁; 列按预期添加
    • 对UsersController和UserSessionsController进行了更改,以使用块来保存每个.
    • 对新的用户会话视图进行了更改以支持open 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)

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' …
Run Code Online (Sandbox Code Playgroud)

openid ruby-on-rails authlogic

9
推荐指数
1
解决办法
1445
查看次数

获取未定义方法'valid_password?'的错误 与Authlogic

我使用Authlogic在服务器上突然出现以下错误

NoMethodError (undefined method `valid_password?' for #<ProductionHouse:0xb53859cc>):

authlogic (2.1.3) [v] lib/authlogic/session/password.rb:191:in `send'

authlogic (2.1.3) [v] lib/authlogic/session/password.rb:191:in `validate_by_password'

authlogic (2.1.3) [v] lib/authlogic/session/callbacks.rb:72:in `validate'

authlogic (2.1.3) [v] lib/authlogic/session/validation.rb:64:in `valid?'

authlogic (2.1.3) [v] lib/authlogic/session/existence.rb:65:in `save'

app/controllers/user_session_controller.rb:162:in `create'

pdfkit (0.5.1) lib/pdfkit/middleware.rb:16:in `call'
Run Code Online (Sandbox Code Playgroud)

不能突然发生这个问题吗?有没有人知道这个,请帮忙吗?

ruby-on-rails authlogic

8
推荐指数
1
解决办法
1272
查看次数

Authlogic和单一访问令牌

我很难找到一个关于如何使用authlogic启用单一访问令牌身份验证的简单教程.有一些文档,但它不是很有帮助.

我将single_access_token添加到我的数据库中,我添加了这个:

  single_access_allowed_request_types :any
Run Code Online (Sandbox Code Playgroud)

到我的Session类.但我仍然不明白如何使用每次调用传递的凭据参数对用户进行身份验证.我在过滤器之前的require_authentication对current_user执行标准检查,如下所示:

 def current_session
    return @current_session if @current_session
    @current_session = Session.find
  end

  def current_user
    @current_user = current_session && current_session.record
  end
Run Code Online (Sandbox Code Playgroud)

但这足以奏效吗?Session.find方法是否可以根据我的参数来记录用户,或者我是否必须创建单独的方法来实际检查user_credentials参数是否存在然后根据它找到用户然后将该用户记录下来.如果我每次使用SAT时都"创建"一个新会话,或者每次进行API调用时我只是在一个before过滤器中设置当前用户,我感到很困惑.

任何帮助都会很棒!谢谢!

ruby ruby-on-rails authlogic ruby-on-rails-3

8
推荐指数
1
解决办法
3166
查看次数

将用户ID预先添加到Rails中的所有日志消息

为了帮助跟踪用户操作以进行调试,我们正在考虑将会话的登录用户ID添加到每个日志消息(如果适用).我们的堆栈由Rails和Authlogic组成.我尝试了几条不同的路线,但到目前为止还没有100%成功.

由于Authlogic不以明文形式在会话数据中存储用户ID,因此我们必须等待它被初始化.只有在ApplicationController初始化并设置为活动的Authlogic控制器之后才会发生这种情况.因此,我们不能依赖代码config/application.rb.在我看来,唯一的解决方案是稍后更换记录器.

我试图通过继承Logger并覆盖add()方法来创建一个新的记录器类:

class UserLogger < Logger
  def add(severity, message = nil, progname = nil, &block)
    begin
      session = UserSession.find
    rescue
      return super(severity, message, progname, &block)
    end

    user = session.user if session

    if block_given? || !user
      return super(severity, message, progname, &block)
    end

    unless message.nil?
      message = "[#{user.id}] " + message
    end

    super severity, message, progname, &block
  end
end
Run Code Online (Sandbox Code Playgroud)

这似乎对原木前哨没有任何影响.我也试过搞乱TaggedLogging,但这似乎不是一个好的解决方案,因为你必须在块中抛出任何标记的代码.

我也尝试config.log_tags通过给它一个Proc来定义应用程序配置,但Authlogic抛出相同的Authlogic::Session::Activation::NotActivatedError异常.试图捕获这个异常使得Ruby变成了一个非常奇怪的状态,似乎是某个无限循环并将​​我的CPU固定在100%.

是否有一个简单的解决方案或一个我完全失踪?

ruby session logging ruby-on-rails authlogic

8
推荐指数
2
解决办法
1024
查看次数