I have a WebAPI that was hosted on IIS and I am attempting to move it into Service Fabric. Everything is working, except for my OpenIdConnect middleware. The redirect to the auth provider never happens. I have it setup to only redirect the user when they hit certain routes with a MapWhen
app.MapWhen(owinContext =>
{
if (owinContext.Request.Path.Value.ToLower().StartsWith("/someroute))
{
return true;
}
return false;
}, adApp => adApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
I can debug into the MapWhen and I see it is returning true, but instead of a redirect nothing happens. Any ideas what could cause the redirect to fail? Is this middleware compatible with a self hosted app?
I ended up removing the middleware and using Thinktecture.IdentityModel.Client.OAuth2Client to initiate a redirect server side instead.
The OpenIdConnect Owin middleware is meant to be used to secure MVC pages. When I removed the MVC routes from my app to go self hosted I beleive that is what broke it.