在研究添加一些新功能的登录系统时,我发现它并不是很安全。认证cookie是由
因此,我在这里和网络上阅读了很多关于安全登录和安全cookie的内容。我能看出来,不安全的做法有多容易。
关于网站:
目标:
用户ID、时间戳、版本、明文密码和cookie ID
加密而成。至少我可以说我不是那样做的人,之前的开发人员这样做了。(是的,我知道应该将密码保存为哈希值而不是明文存储在数据库中。原始开发人员是这样做的,我还没有修复这个问题。)因此,我在这里和网络上阅读了很多关于安全登录和安全cookie的内容。我能看出来,不安全的做法有多容易。
关于网站:
- 这是一个电子商务网站,也有很多社区功能(留言板、画廊)
- 登录页面强制使用HTTPS
- 所有账户页面和结算页面也强制使用HTTPS
- 更改密码或电子邮件地址需要提供当前密码
目标:
- beable to be logged in in more than one place
- need to relogin for secure parts of the store, only lasts 30-60 min, cookie set secure only
- option to see all current logins
- option to log out in all places
backend login is secure, and lasts longer. limited login for outside of office
user gets page: no auth: have user sign in with username & pass create new token expires = https on store: 30-60 min backend in office: 5 days backend remote: 30-60 min? regular without remember me: session or 24 hours? regular with remember me: 30 days insert into user_session set cookie auth: token in db: set uid generate new token, new expires, insert into DB, remove old? upddate cookie token not in db: logout, requre sign in table user_session: uid uid_as (for being 'logged in' as another user, admin feature only) token type ip address expires stamp cookie value: token|hash(token + user id, server key)
根据我所阅读的所有内容,这就是我的结论。但我感觉好像还有什么遗漏。除了为整个站点使用HTTPS以外,是否还有其他方法可以使其更加安全?(目前这样做会引起一些问题,但我稍后会研究这个问题)