【问题标题】:Rails 3 Authlogic problem with single access token and logout on timeoutRails 3 Authlogic问题与单一访问令牌和超时注销
【发布时间】:2011-07-15 06:14:09
【问题描述】:

当超时注销设置为 true 并设置超时时,我在使用 authlogic 单一访问令牌访问页面时遇到问题。

user.rb:

acts_as_authentic do |c|
  c.logged_in_timeout = 15.minutes
end

user_session.rb:

logout_on_timeout true

控制器:

def single_access_allowed?
  ["download_xml"].include?(action_name)
end

如果我尝试使用令牌访问页面/方法,它会直接重定向到我的登录页面。超时注销在开启时起作用。

如果我删除超时代码并在 user.rb 中只包含acts_as_authentic,则单一访问令牌有效。

我希望能够使用单一访问令牌,以便另一个应用程序可以从我的 ruby​​ on rails 网站打开一个 xml 文件。

关于我可能做错了什么以及在哪里寻找解决它并使其发挥作用的任何想法?

使用 authlogic 3.0.3 和 rails 3.0.7。

【问题讨论】:

  • 如果有人有任何想法,我还没有弄清楚这个?
  • 在 github 上发现这是 authlogic 的一个未解决问题 -> github.com/binarylogic/authlogic/issues/64 mhaley 说:“如果您只想解决应用程序中的问题,您可以像这样修改 UserSession 模型:” class UserSession :single_access? after_persisting :enforce_timeout, :unless => :single_access? end 但是,单个访问令牌有效,但超时注销停止工作。

标签: ruby-on-rails-3 authlogic


【解决方案1】:

jgdreyes 去年 9 月 27 日在https://github.com/binarylogic/authlogic/issues/64 的回复对我有用:

我继续扩展 Authlogic 的陈旧性?方法,这样它就可以了 没有看到请求过时?如果通过 single_access 访问?这保持 logout_on_timeout 的逻辑完好无损。

class UserSession < Authlogic::Session::Base   logout_on_timeout true
  def stale?
    return false if single_access?
    super   
  end 
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-28
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    • 2011-10-20
    • 2019-08-03
    • 1970-01-01
    相关资源
    最近更新 更多