对LOCAL AUTHORITY索赔和外部提供商的索赔感到混乱 [英] Confusion over LOCAL AUTHORITY claims and External Provider claims
问题描述
我正在创建一个简单的WebApi,它允许用户与Facebook连接。当我从Facebook上获取accessToken时,我打电话给RegisterExternal创建一个Asp.Net身份记录,并存储令牌的声明。这些索赔还包括稍后查询Facebook图表所需的访问令牌。所有这一切似乎都很好了。
我遇到的问题是阅读索赔。我可以看到他们在我的数据库我只是不知道如何查询这些数据。我试过
var claimsIdentity = User.Identity as ClaimsIdentity;
但这会返回2
a的索赔) http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
b)角色
这两个都是发行者LOCAL AUTHORITY(说实话我不知道什么时候被创建,因为我没有明确添加这些) 。所以我相信他们是对我的混淆,把索赔保存到数据库中再次出现错误的发行者类型
await userManager.AddClaimAsync user.Id,new Claim(urn:facebook:access_token,accessTokenClaim.Value,ClaimValueTypes.String,LOCAL AUTHORITY));
或我访问声明的代码不正确。
/ p>
当我重新命名身份cookie时,我有同样的问题。所以我有2个不同的用户在2个饼干。之后我删除了旧的一个问题。
I am creating a simple WebApi which allows users to connect with Facebook. When I get the accessToken back from facebook, I am calling RegisterExternal to create an Asp.Net Identity record and store the Claims from the token. These claims also include the access token which I require to query the facebook graph later. All seems fine up to this point.
The issue I am having is reading the claims. I can see they are in my database I just cant figure out how to query this data. I have tried
var claimsIdentity = User.Identity as ClaimsIdentity;
But this returns me 2 claims for a) "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" b) role
Both of these are of issuer LOCAL AUTHORITY (to be honest I am not sure when they are created as I am not explicitly adding these). So I believe their is either confusion on me saving the claims to the database agains the wrong type of issuer
await userManager.AddClaimAsync(user.Id, new Claim("urn:facebook:access_token", accessTokenClaim.Value, ClaimValueTypes.String, "LOCAL AUTHORITY"));
or my code for accessing the claims is incorrect.
Can anybody shed some light on this?
I had the same issue when I renamed identity cookie. So I had 2 different users in 2 cookies. After I deleted the old one issue is gone.
这篇关于对LOCAL AUTHORITY索赔和外部提供商的索赔感到混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!