Session_controller: Force SSL setting messes up SSO process

I’m facing this exact same problem using the latest version of Discourse: v2.4.0.beta4

Does anyone here have any clues about how to solve this?