You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Validation support for instances behind load balancers (haproxy) #75
I have Heroku/Docker-like deployment, and I'm getting the following error:
The response was received at http://{{PUBLIC_IP}}:{{INNER_PORT}}/saml2/acs/ instead of https://service-provider.com/saml2/acs/
And the SAMLResponse is not validating.
For my particular installation, this two urls are never going to match. I wonder if there's a way to circumvent this issue, or does this need changes in the code?
Looking for X-FORWARED-FOR header for example?
I was using the prepare_request approach as in the example:
defprepare_django_request(request):
# If server is behind proxys or balancers use the HTTP_X_FORWARDED fieldsresult= {
'https': 'on'ifrequest.is_secure() else'off',
'http_host': request.META['HTTP_HOST'],
'script_name': request.META['PATH_INFO'],
'server_port': request.META['SERVER_PORT'],
'get_data': request.GET.copy(),
'post_data': request.POST.copy()
}
returnresult
So I just needed to rearrange this, in order to meet my requirements:
http_host=request.META.get('HTTP_HOST', None)
if'HTTP_X_FORWARDED_FOR'inrequest.META:
# This is only true for my particular installations.server_port=Nonehttps=request.META.get('HTTP_X_FORWARDED_PROTO') =='https'else:
server_port=request.META.get('SERVER_PORT')
https=request.is_secure()
prepared= {
'https': 'on'ifhttpselse'off',
'http_host': http_host,
'script_name': request.META['PATH_INFO'],
'get_data': request.GET.copy(),
'post_data': request.POST.copy()
}
ifserver_port:
# Empty port will make a (lonely) colon ':' appear on the URL, so# it's better not to include it at all.prepared['server_port'] =server_portreturnprepared
Reacted by Doodad/Doodead, Nuno Khan, Mohamed Moursi, Michael Thompson and Corentin Smith
Activity
pitbulk commentedon Jun 3, 2015
@serpulga Have you closed this ticket accidentally ? or have you fixed it?
serpulga commentedon Jun 3, 2015
@pitbulk
I decided this is a non-issue.
I was using the
prepare_requestapproach as in the example:So I just needed to rearrange this, in order to meet my requirements:
pitbulk commentedon Jun 3, 2015
Nice, maybe in the future, we can publish in the README configurations for some well known Servers/Environments.