简体   繁体   English

Asp.Net中基于声明的身份

[英]Claims based Identity in Asp.Net

When working with Claims based identity with AspNet, in my case just using the templates coming with Visual studio 2013. 在AspNet中使用基于声明的身份时,在我的情况下,仅使用Visual Studio 2013随附的模板。

Taking the EntityFramework implementation of Microsoft.AspNet.Identity and looking at the User Model class. 采取Microsoft.AspNet.Identity的EntityFramework实现,并查看User Model类。

Is it the intention that one put profile info into claims or to extend the user model with additional properties? 是否打算将个人档案信息放入声明中或使用其他属性扩展用户模型?

An example would be, I want to add a country associated with each user and edits the registration flow such user can give this information. 例如,我想添加与每个用户相关联的国家/地区,并编辑注册流程,以便该用户可以提供此信息。 Should I put this on the user or add it as a claim for that user. 我应该将其放置在用户身上还是将其添加为该用户的声明。

To follow on from my comments, you want to put any user-specific settings (ie 1:1 relationship ) into the user table and not the claims table. 为了继续我的评论,您想要将任何特定于用户的设置(即1:1关系)放入用户表中,而不是声明表中。 That would apply to your profile settings 这将适用于您的个人资料设置

The claims table is per external claim . 索赔表是根据外部索赔确定的 Although claims may contain duplicate values, they allow for the values (even name) to vary from site to site. 尽管声明可能包含重复的值,但它们允许值(甚至名称)在站点之间有所不同。 It is after all only the value the user stated when they signed up to the external website. 毕竟,这只是用户注册外部网站时所声明的价值。

There is also the facility to add additional separate tables, that relate to the user table, but probably not worth the extra effort for profile data. 还有一种工具可以添加与用户表相关的其他单独的表,但是可能不值得为配置文件数据付出额外的精力。

* Note: there appear to be problems using database-first with asp.net identity, so you will likely need to make model-first changes and use database migration to update your database (which we wound up doing) * 注意:使用具有asp.net身份的数据库优先似乎存在问题,因此您可能需要进行模型优先更改并使用数据库迁移来更新数据库(我们最终将这样做)

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

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