什么是ASP.NET Identity中的安全性令牌和安全性标记?

问题描述:

我需要有关ASP.NET Identity的两个功能的背景知识:

I need background about two features of ASP.NET Identity please:

  1. 安全令牌-这是什么?是发送给用户电子邮件的临时密码吗?
  2. 安全性标记-除了安全性令牌以外,还有其他东西吗?如果是,它的目的是什么?它们有什么不同?
  1. Security token - What is it? is it a temporary password sent to the user's email?
  2. Security Stamp - Is it something else than security tokens? If yes, what's its purpose? how are they different?

谢谢, ashilon

Thanks, ashilon

尝试依次回答您的问题:

Try to answer your questions in order:

  1. 令牌在身份中以多种方式使用.您可以使用它们来重置密码或确认用户的电子邮件地址.在这里,您将为特定用户生成一个特定的令牌,该令牌可用于这两个目的.它们将被发送给用户,例如作为处理确认​​的视图的链接.您还可以在将令牌提供给用户时重写令牌(这是一个很长的令牌),但是在确认过程中撤消重写是很重要的.通常,当您在身份"中引用令牌时,它表示用于认证用户的承载令牌.这是一个已签名的令牌,没有存储在服务器上.
  2. 安全时间戳记用于跟踪对用户配置文件所做的更改.当用户的重要属性发生更改(例如更改密码)时,它用于安全目的.通常,您不必直接使用时间戳,但是如果在播种数据库时以代码优先的方式添加默认用户,则必须设置安全时间戳.如果不这样做,则必须采取一些手动步骤来使用这些用户.

大多数这些都由Identity本身处理,但是当您想要进行一些自定义时,您将需要一些知识.如果您想深入了解Brock Allen的博客是一个很好的资源,因为官方文档缺少一些重要的内容并且通常不是最新的.

Most of these are mostly handled by Identity itself, but you will need some knowledge when you want to do some customization. If you want to dig deeper the blog of Brock Allen is a good resource, because the official documentation lacks some of the important things and is normally not up-to-date.