【发布时间】:2016-03-26 19:27:36
【问题描述】:
我有一个 IdentityServer,只有一个混合流客户端,它为 AllowedScopes 设置 "all_claims"。在另一台计算机上,我有一个连接到 IdSvr 以登录用户的 MVC 应用程序。它还为 IdMgr 设置了 /admin 绑定。我可以毫无问题地登录到主应用程序和 IdMgr。同样在用户登录后的主应用程序中,我按预期获得了所有声明,但在 IdMgr 中没有。
我正在尝试根据声明在 IdMgr 中添加一些自定义逻辑。但是当我在任何 IdMgr 控制器中得到Thread.CurrentPrincipal 时,它是空的!我得到的只是一个只有角色声明的 ClaimsPrincipal 对象。它还有一个 ClaimsIdentity 对象,具有以下属性:
AuthenticationType: "Bearer"
IsAuthenticated: true
NameClaimType: "name"
RoleClaimType: "role"
其他的都是空的。甚至没有用户的名称或 ID。为什么会这样?如何在 IdentityManager 中获取所有声明?
要重现这一点,只需检查 UsersController 中的 GetUsersAsync 方法中的 System.Threading.Thread.CurrentPrincipal。
在 GitHub 上链接到此 issue
【问题讨论】:
标签: asp.net-identity claims-based-identity thinktecture-ident-server identityserver3 identitymanager