IdentityServer / IdentityServer3.AccessTokenValidation

OWIN Middleware to validate access tokens from IdentityServer3
Apache License 2.0
90 stars 149 forks source link

In memory Integration test for IdSrv3 and API hostet in a single project, using OwinHttpMessageHandler #78

Closed dprochownik closed 8 years ago

dprochownik commented 8 years ago

Are there any chances that BackchannelHttpHandler in IdentityServerBearerTokenAuthenticationOptions will be an expression instead of object instance or there will be some other possibility for lazy set of back channel?

I mean by this something like BackchannelHttpHandler = () => myCustomInMemoryOwinHttpMessageHandler

When IdSrv3 and API which uses app.UseIdentityServerBearerTokenAuthentication(authOptions) are hosted in a single OWIN project, and both are set up in a single application startup, there is no possibility to set BackchannelHttpHandler for in-memory integration testing because OwinHttpMessageHandler could be created only after app.Build().

Sample of using OwinHttpMessageHandler can be found here: http://dhickey.ie/2015/04/testing-owin-applications-with-httpclient-and-owinhttpmessagehandler/

Code-Grump commented 8 years ago

Would it be possible use a simple handler which accepts a delegate?

public class Handler : System.Net.Http.HttpMessageHandler
{
    private readonly Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> SendCoreAsync;

    public Handler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> sender)
    {
        SendCoreAsync = sender;
    }

    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        return SendCoreAsync(request, cancellationToken);
    }
}
brockallen commented 8 years ago

Why not host them in 2 different pipelines?