在 ASP.NET 5 MVC 6 中处理密码更改
Handling password change in ASP.NET 5 MVC 6
想象一下下面的场景。
用户已通过身份验证并获得身份验证 cookie。这意味着不应再次输入用户名和密码。
我只在身份验证 cookie 中存储用户名。
黑客以某种方式窃取了用户的身份验证 cookie。管理员决定更改用户的密码,但黑客仍然通过身份验证并可以访问系统!
据我所知,身份验证 cookie 无法在服务器端以外的任何地方解密,不是吗?
将密码或密码散列作为自定义声明存储在身份验证 cookie 中是否安全,这样我可以稍后比较它并从受歧视的用户中删除身份验证?
它的最佳实践是什么?还是我在做或问的事情完全错误?
As far as I can understand authentication cookie can't be decrypted
anywhere but serverside, isn't it?
身份验证 Cookie 使用机器密钥加密。没有机器密钥很难解密回来,但并非不可能。
Is it safe to store a password or a password hash as a custom claim in
authentication cookie so I can compare it later and remove
authentication from discriminated users? What's a best practice for
it? Or am I doing or asking something completely wrong?
不,您不想在声明中存储密码。它不会解决黑客问题,甚至不会使它变得更糟。
您可以实现 security stamp 之类的 ASP.Net 身份,基本上可以从任何地方注销用户。
想象一下下面的场景。
用户已通过身份验证并获得身份验证 cookie。这意味着不应再次输入用户名和密码。 我只在身份验证 cookie 中存储用户名。
黑客以某种方式窃取了用户的身份验证 cookie。管理员决定更改用户的密码,但黑客仍然通过身份验证并可以访问系统!
据我所知,身份验证 cookie 无法在服务器端以外的任何地方解密,不是吗?
将密码或密码散列作为自定义声明存储在身份验证 cookie 中是否安全,这样我可以稍后比较它并从受歧视的用户中删除身份验证? 它的最佳实践是什么?还是我在做或问的事情完全错误?
As far as I can understand authentication cookie can't be decrypted anywhere but serverside, isn't it?
身份验证 Cookie 使用机器密钥加密。没有机器密钥很难解密回来,但并非不可能。
Is it safe to store a password or a password hash as a custom claim in authentication cookie so I can compare it later and remove authentication from discriminated users? What's a best practice for it? Or am I doing or asking something completely wrong?
不,您不想在声明中存储密码。它不会解决黑客问题,甚至不会使它变得更糟。
您可以实现 security stamp 之类的 ASP.Net 身份,基本上可以从任何地方注销用户。