Skip to content

Commit 5226956

Browse files
committed
Solve HTTPs issue on demos
1 parent 698d8ae commit 5226956

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

demo-django/demo/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def init_saml_auth(req):
1515

1616

1717
def prepare_django_request(request):
18+
# If server is behind proxys or balancers use the HTTP_X_FORWARDED fields
1819
result = {
20+
'https': 'on' if request.is_secure() else 'off',
1921
'http_host': request.META['HTTP_HOST'],
2022
'script_name': request.META['PATH_INFO'],
2123
'server_port': request.META['SERVER_PORT'],

demo-flask/index.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ def init_saml_auth(req):
2020

2121

2222
def prepare_flask_request(request):
23+
# If server is behind proxys or balancers use the HTTP_X_FORWARDED fields
2324
url_data = urlparse(request.url)
2425
return {
26+
'https': 'on' if request.scheme == 'https' else 'off',
2527
'http_host': request.host,
2628
'server_port': url_data.port,
2729
'script_name': request.path,
@@ -121,4 +123,5 @@ def metadata():
121123

122124

123125
if __name__ == "__main__":
124-
app.run(host='0.0.0.0', port=8000, debug=True)
126+
ssl_context = ('/home/pitbulk/proyectos/python-saml/demo-flask/saml/certs/sp.crt', '/home/pitbulk/proyectos/python-saml/demo-flask/saml/certs/sp.key')
127+
app.run(host='0.0.0.0', port=444, debug=True, ssl_context=ssl_context)

0 commit comments

Comments
 (0)