简体   繁体   English

PersonalDataAttribute 有什么用?

[英]What's the PersonalDataAttribute good for?

I just stumbled over the fact that ASP.NET Core Identity framework offers a PersonalData attribute .我只是偶然发现 ASP.NET Core Identity 框架提供了PersonalData 属性 The docs merely say:文档只是说:

Used to indicate that a something is considered personal data.用于表示某物被视为个人数据。

Okay.好的。 What does it mean?这是什么意思? Does it have any implication on how the identity frameworks works or what it does?它对身份框架的工作方式或作用有什么影响吗? Or is it purely decorative, so that I can do some reflection on some objects and document my code?或者它纯粹是装饰性的,以便我可以对某些对象进行一些反思并记录我的代码?

The ASP.NET Core Identity UI includes a "Download Personal Data" page, which uses the [PersonalData] attribute to help determine what to include in the download ( source ): ASP.NET Core 标识 UI 包括一个“下载个人数据”页面,该页面使用[PersonalData]属性来帮助确定要在下载中包含的内容( 来源):

 // Only include personal data for download var personalData = new Dictionary<string, string>(); var personalDataProps = typeof(TUser).GetProperties().Where( prop => Attribute.IsDefined(prop, typeof(PersonalDataAttribute))); foreach (var p in personalDataProps) { personalData.Add(p.Name, p.GetValue(user)?.ToString() ?? "null"); }

There's also [ProtectedPersonalData] , which inherits from [PersonalData] .还有[ProtectedPersonalData] ,它继承自[PersonalData] This attribute also configures Identity's EF Core integration to encrypt the property when it's stored in the database.此属性还将 Identity 的 EF Core 集成配置为在属性存储在数据库中时对其进行加密。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM