【发布时间】:2014-07-22 15:58:08
【问题描述】:
我正在使用 Owin 和 Identity,但我遇到了声明问题。
我有一些应用程序,其中用户使用电子邮件进行身份验证,而其他应用程序则使用用户名。
业务层中的登录方法可以根据情况接受电子邮件或用户名。
-
为了“混淆”用户身份,我在显示包含用户信息的页面时使用每个用户唯一的 GUID。
我也使用它,因为有时电子邮件或用户名可能是 url 中的问题...
当我签署用户时,我有以下声明类型:
new Claim(ClaimTypes.Email, user.Email),
new Claim(ClaimTypes.Name, user.FullName),
new Claim(ClaimTypes.GivenName, user.FirstName),
new Claim(ClaimTypes.Surname, user.LastName),
new Claim(ClaimTypes.NameIdentifier, user.UserUniqueIdentifier.ToString())
所以我的解释是:
Email is the user's email
Name is the user's full name
GivenName is the user's first name
Surname is the user's last name
NameIdentifier is the user's unique identifier ... It can be the email, the username or in this case I am using an Unique ID.
奇怪的是用户名没有声明类型。放在哪里?
基本上,当用户名不用作唯一名称标识符时似乎存在问题,但它仍然是必需的。
我的逻辑声明类型有问题吗?
【问题讨论】:
标签: asp.net-mvc owin