首页 > 解决方案 > 密码重置令牌泄露给谷歌分析

问题描述

当用户单击电子邮件中的链接以重置令牌时,我的重置密码令牌泄漏给谷歌分析。 http://localhost:5000/users/password/edit?reset_password_token=g1xMHpjsDEE3MkMFUapo

检查后我可以看到

https://www.google-analytics.com/collect?v=1&_v=j73&a=1182934228&t=event&ni=1&_s=1&dl=http%3A%2F%2Flocalhost%2Fusers%2Fpassword%2Fedit%3Freset_password_token%3Dg1xMHpjsDEE3MkMFUapo&ul=en-us&de= UTF-8&dt=ABC&sd=24-bit&sr=1366x768&vp=1286x247&je=0&ec=Scroll%20Depth&ea=%2Fusers%2Fpassword%2Fedit&el=25%25&_utma=111872281.1944961626.1546492539.1548676828.1548676828.1&_utmz=111872281.1548676828.1.1.utmcsr%3D(direct)%7Cutmccn %3D(direct)%7Cutmcmd%3D(none)&_utmht=1550758398105&_u=QACCAEAB~&jid=&gjid=&cid=1944961626.1546492539&tid=UA-25463847-1&_gid=1342755913.1550758313>m=2wg241WZ6LHH2&z=1855597746

尝试了以下链接,但没有用,请帮助。

https://thoughtbot.com/blog/is-your-site-leaking-password-reset-links

https://github.com/thoughtbot/clearance/pull/707

https://github.com/thoughtbot/clearance/pull/706

我的 passwords_controller.rb

def create self.resource = resource_class.send_reset_password_instructions(resource_params) 如果 block_given 产生资源?

if successfully_sent?(resource)
  respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
else
  respond_with(resource)
end

结尾

def edit self.resource = resource_class.new resource.reset_password_token = params[:reset_password_token] end

标签: ruby-on-rails

解决方案


您可以从该特定页面中删除 Google Analytics 脚本。

我假设您在应用程序布局文件中导入脚本,因此您有两个选择:

  • 为用户模型创建一个单独的布局文件。
  • 在当前布局文件中放置一个条件以检查控制器,如果它正在重置用户密码,则不导入谷歌分析。

如果你做两者之一,它应该停止“泄漏”。


推荐阅读