2

排查问题时,如何使用用户身份登录

 2 years ago
source link: https://zzyongx.github.io/blogs/login-without-username-password-when-troubleshoot.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

排查问题时,如何使用用户身份登录

有时候用户的页面展示出了问题,数据缺失,或者不正确,而开发者自己的页面没有问题时,最快的排查方法,无疑是使用用户的用户名、密码登陆,实际看看出了什么问题。找用户要人家的用户名和密码,这个怎么开的了口?其实完全不需要,我们需要的仅仅是用户的登陆cookie而已。用户的登陆cookie当然保存在我们的服务器了。

首先我们在服务端找到用户的cookie,然后通过浏览器开发者工具设置cookie,假设cookie是 token=5486935081fcf3a8cbf8a0321f20d199

document.cookie="token=5486935081fcf3a8cbf8a0321f20d199";

这样我们就“窃取”了用户身份,可以看看到底是哪里出了问题。对于HttpOnly的cookie,需要先用开发者工具手动清理cookie,然后再设置

对于安全性高的应用,为了防止开发人员“窃取”用户身份,可能需要一些cookie设置规则,无法从用户ID查cookie,只能从cookie查用户ID。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK