Rails 3 Devise Warden登录的安全漏洞需要堵住,把我的头发拔了出来



我的登录功能有问题。

  1. 当用户在正常工作的情况下单击注销链接时,会话将被破坏,用户可以以其他用户身份登录
  2. 如果当前登录的用户关闭浏览器并返回登录页面,或者如果用户只是按下登录页面的后退按钮并且尝试以不同用户的身份登录时,用户被引导到先前登录到该特定浏览器上的应用程序的用户
    这是不需要的功能。我想让用户能够登录到他们想要的任何帐户,而不管无论用户是否返回登录页面,或者关闭窗口返回登录页面。

    我尝试了6种不同的解决方案,但都没有奏效。似乎无论我对代码做了什么更改,登录功能都会拉会话[:warden.user.perse.key]中的用户id散列,并使用它进行登录,无论登录文本字段中输入了什么。我试图控制这个过程但每次尝试都失败了。

    我已经没有什么想法了,需要一些帮助,因为这被认为是我们系统中的一个安全漏洞
    请让我知道你还想看什么代码。我给你会话控制器代码和我的路线。

 
class SessionsController  Devise::SessionsController
  def new
    session["devise.omniauth_data"]=nil
    session[:last_registration_role]=nil
    super
  end
  def create
    if params['person']['remember_me'] == '1'
      cookies.signed['rem'] = {
        :value => params['person']['email'],
        :expires => 1.year.from_now,
        :httponly => true
      }
    end
    super
  end
  def destroy
    session["devise.omniauth_data"]=nil
    session[:last_registration_role]=nil
    super
    reset_session
  end    
end

路由


                     new_person_session GET      /people/sign_in(.:format)                                                                           {:action=>"new", :controller=>"sessions"}
                                    person_session POST     /people/sign_in(.:format)                                                                           {:action=>"create", :controller=>"sessions"}
                            destroy_person_session GET      /people/sign_out(.:format)                                                                          {:action=>"destroy", :controller=>"sessions"}
                                   person_password POST     /people/password(.:format)                                                                          {:action=>"create", :controller=>"devise/passwords"}
                               new_person_password GET      /people/password/new(.:format)                                                                      {:action=>"new", :controller=>"devise/passwords"}
                              edit_person_password GET      /people/password/edit(.:format)                                                                     {:action=>"edit", :controller=>"devise/passwords"}
                                                   PUT      /people/password(.:format)                                                                          {:action=>"update", :controller=>"devise/passwords"}

在您的application_controller中,尝试设置您希望在登录后发送人员的确切位置:

def after_sign_in_path_for(resource)
  root_path
end

最新更新