【问题标题】:Bruteforce protection with authlogic, Rails3.0.10使用 authlogic 进行蛮力保护,Rails3.0.10
【发布时间】:2012-04-14 14:32:05
【问题描述】:

我想使用 authlogic 的蛮力功能,但不知道如何配置它。我的user_session.rb 模型如下所示:

class UserSession < Authlogic::Session::Base

#edited code to ensure specific login error isn't displayed

    generalize_credentials_error_messages "Login/password invaild"


    #brute force protection
    consecutive_failed_logins_limit 3


    #orginal code commented out
        #def to_key
        #new_record? ? nil : [ self.send(self.class.primary_key) ]
        #end
        #def persisted?
        #false
        #end

end

我知道我需要比这更多的配置,但是什么?任何帮助表示赞赏。

【问题讨论】:

    标签: ruby-on-rails authlogic brute-force


    【解决方案1】:

    您需要添加 Continuous_failed_logins_limit 和可选的 failed_login_ban_for。我在下面展示了一个使用 Authlogic 的默认设置的示例。您不需要为这些值定义和使用常量,但我喜欢这样做,以便可以从任何地方以编程方式引用这些值。

    class UserSession < Authlogic::Session::Base
      MAXIMUM_NUMBER_OF_FAILED_LOGIN_ATTEMPTS_ALLOWED = 50
      consecutive_failed_logins_limit MAXIMUM_NUMBER_OF_FAILED_LOGIN_ATTEMPTS_ALLOWED
    
      LOCKOUT_TIMEOUT_PERIOD = 2.hours
      failed_login_ban_for LOCKOUT_TIMEOUT_PERIOD
    
    ...
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      • 1970-01-01
      • 2020-12-16
      • 2018-06-05
      • 2021-10-20
      • 2019-03-03
      相关资源
      最近更新 更多