asp.net mvc - MVC 5 app - facebook app redirects to the wrong URI - redirect_uri=http instead of redirect_uri=https -
i have app in facebook developer. app configured "valid oauth redirect uris"-value url https. when click on login facebook button on page facebook redirects me http version of uri. seems facebook bug in oauth module?
i had issue when deployed aws elastic beanstalk environment ssl terminated @ load-balancer. in case, request received load-balancer server looks client connecting http, , owin providers incorrectly infer url facebook/twitter/google needs connect site should use http instead of https on public side of load-balancer.
i couldn't find simple solution this, there didn't seem parameters override uri protocol gets stored in iowinrequest.scheme
property. in end, grabbed source code katana project, , source code asp.net identity project, , hacked around bit had local projects in solutions for:
- microsoft.aspnet.identity.core
- microsoft.aspnet.identity.entityframework
- microsoft.aspnet.identity.owin
- microsoft.owin.security.cookies
- microsoft.owin.security.facebook
- microsoft.owin.security.google
- microsoft.owin.security.oauth
- microsoft.owin.security.twitter
there 50 or other projects within katana left out - made of these other dependencies nuget package references official versions.
then found every reference iowinrequest.scheme
, , replaced snippet of code looked x-forwarded-proto header injected load-balancer when using ssl offloading.
something this:
var scheme = request.scheme; if (string.equals(request.headers["x-forwarded-proto"], "https", stringcomparison.invariantcultureignorecase)) { scheme = "https"; } // use scheme in construction of uri...
if load-balancer or proxy server doesn't provide x-forwarded-proto header, options pretty limited. re-encrypt traffic , send on server using same protocol came in on.
Comments
Post a Comment