【发布时间】:2012-04-21 02:18:42
【问题描述】:
请根据以下要求提供您对我的解决方案的反馈。
要求(类似):
1.a 假设身份验证令牌由电子邮件和日期组成并被加密
1.b authentication Token通过header发回给客户端
1.c authentication Token存储在客户端和服务器上
我的解决方案:
1) 通过 header 将 authentication Token 发送回客户端。我使用了 cookie 和以下代码。
HttpCookie cookie = new HttpCookie("AuthenticationToken");
cookie.Value = "EncryptedToken";
Response.Cookies.Add(cookie);
2) 我会将身份验证令牌存储在数据库中,并且对于每个请求,我都会将保存在 cookie 中的令牌与存储在数据库中的令牌进行比较。 (假设加密、解密操作正确完成)
您的反馈/意见?
【问题讨论】:
-
Cookies 适用于网络浏览器,但如果您还希望针对移动和桌面客户端,您可能需要考虑其他内容
-
你是对的。我最终使用了 sqllite,并通过 http 标头发送身份验证令牌。
标签: restful-authentication asp.net-mvc-4 asp.net-web-api