在自托管IdentityServer3 CustomGrant Validator中访问IOwinRequest

时间:2016-07-21 17:44:29

标签: dependency-injection owin identityserver3

我正在使用自托管(即控制台应用)IdentityServer3应用程序。我已经实现了CustomGrant验证器。

如何从此CustomGrantValidator访问IOwinRequest和IOwinResponse上下文?

可以使用依赖注入吗?

2 个答案:

答案 0 :(得分:1)

IdentityServer的DI服务可通过ResolveDependency OWIN扩展程序https://identityserver.github.io/Documentation/docsv2/advanced/owin.html获得。要使用这些OWIN扩展,您的代码必须在IdentityServer之后的管道中运行。

答案 1 :(得分:1)

您可以将OwinEnvironmentService注入验证程序。

从那里你可以创建像

这样的OwinContext

var context = new OwinContext(owinEnvironmentService.Environment);

上下文又包含请求和响应对象。