Applications in AppHarbor sit behind the NGINX load balancer. Because of this, all requests that fall into the client application will be processed via HTTP, since SSL will be processed by this interface.
ASP.NET MVC OAuth 2 OAuthAuthorizationServerOptions has options for restricting access to token requests for HTTPS use only. The problem is that, unlike Controller or ApiController, I don’t know how to allow these forwarded requests when I specify AllowInsecureHttp = false.
In particular, in app startup / config:
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions {
AllowInsecureHttp = true,
});
You need to somehow perform this check inside, and if it is true, treat it like SSL:
HttpContext.Request.Headers["X-Forwarded-Proto"] == "https"
Here, as I do, using the MVC controller, applying a special filter attribute:
https://gist.github.com/runesoerensen/915869
source
share