From e4c8c3892f42fd8451ebe7b1c42e9d2091a73bc6 Mon Sep 17 00:00:00 2001 From: pixelrebel Date: Thu, 19 May 2022 19:00:38 -0700 Subject: [PATCH] Use HTTP_X_FORWARDED_PROTO header from reverse proxy to rewrite https:// for SAML request URLs --- powerdnsadmin/services/saml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerdnsadmin/services/saml.py b/powerdnsadmin/services/saml.py index 67255ca..4a33ee6 100644 --- a/powerdnsadmin/services/saml.py +++ b/powerdnsadmin/services/saml.py @@ -72,8 +72,9 @@ class SAML(object): def prepare_flask_request(self, request): # If server is behind proxys or balancers use the HTTP_X_FORWARDED fields url_data = urlparse(request.url) + proto = request.headers.get('HTTP_X_FORWARDED_PROTO', request.scheme) return { - 'https': 'on' if request.scheme == 'https' else 'off', + 'https': 'on' if proto == 'https' else 'off', 'http_host': request.host, 'server_port': url_data.port, 'script_name': request.path,