twitter / finatra

Fast, testable, Scala services built on TwitterServer and Finagle
https://twitter.github.io/finatra/
Apache License 2.0
2.27k stars 408 forks source link

Location scheme should not always correspond to X-Forwarded-Proto #542

Open modernptz opened 4 years ago

modernptz commented 4 years ago

Since 20.5.0

Expected behavior

It should be possible to make redirect from http to https and vice versa.

Actual behavior

Currently all Location headers which contains absolute uri are being rewritten by HttpResponseFilter with x-forwarded-proto value as uri scheme.

https://github.com/twitter/finatra/blob/b6453a4d0b047e965b5d43f319d028739b80d5d3/http/src/main/scala/com/twitter/finatra/http/filters/HttpResponseFilter.scala#L94

https://github.com/twitter/finatra/blob/b6453a4d0b047e965b5d43f319d028739b80d5d3/http/src/main/scala/com/twitter/finatra/http/filters/HttpResponseFilter.scala#L114

cacoco commented 4 years ago

@modernptz the use of x-forwarded-proto is intentional and is only used if the passed value is different than the returned Location header's current scheme is thus intended to do just what you're asking which is be able to switch from http to https (or vice versa) but always based on the x-forwarded-proto value. That is if you're returning an http scheme but the client's originating protocol was actually https.

Are you asking for a way to ignore the x-forwarded-proto header value to be able to return a scheme that is different than the client's originating protocol?