如何从ClaimsTransformationContext检索访问令牌

时间:2017-03-13 14:13:45

标签: asp.net-core identityserver4

我正在使用Identity Server 4来保护mvc应用和所有外围API。在主体创建期间,我正在使用声明转换中间件,我想在其中调用安全API以获取更多信息。

声明转换中间件在Configure方法中连接如下:

 app.UseClaimsTransformation(o => new ClaimsTransformer().TransformAsync(o));

ClaimsTransformer类看起来像:

   public async Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext    context)
   {
       // meat and potatoes goes here...
       return context.Principal;
   }

我尝试使用ClaimsTransformationContext中的以下代码从TransformAsync获取访问令牌,但是这似乎导致无限循环返回TransformAsync方法{ {1}}上课。

ClaimsTransformer

是否可以在.net核心声明转换期间检索访问令牌?

或者,这个特定的API调用是不应该代表用户完成的,并且更好地处理一步并适合更多服务器到服务器的方法(客户端凭证授权)?

0 个答案:

没有答案
相关问题