changeset 6455d1dbf4d5 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=6455d1dbf4d5
description:
Support secure URL when SSL is delegated
issue9986
review353161002
diffstat:
bin/trytond | 10 ++++++++++
doc/topics/configuration.rst | 4 ++++
trytond/url.py | 8 +++++---
3 files changed, 19 insertions(+), 3 deletions(-)
diffs (53 lines):
diff -r 338781cb8e2a -r 6455d1dbf4d5 bin/trytond
--- a/bin/trytond Sun Feb 14 15:56:18 2021 +0100
+++ b/bin/trytond Mon Feb 15 19:09:44 2021 +0100
@@ -40,7 +40,17 @@
thread.join()
hostname, port = split_netloc(config.get('web', 'listen'))
certificate = config.get('ssl', 'certificate')
+ try:
+ if config.getboolean('ssl', 'certificate'):
+ certificate = None
+ except ValueError:
+ pass
privatekey = config.get('ssl', 'privatekey')
+ try:
+ if config.getboolean('ssl', 'privatekey'):
+ privatekey = None
+ except ValueError:
+ pass
if certificate or privatekey:
from werkzeug.serving import load_ssl_context
ssl_args = dict(
diff -r 338781cb8e2a -r 6455d1dbf4d5 doc/topics/configuration.rst
--- a/doc/topics/configuration.rst Sun Feb 14 15:56:18 2021 +0100
+++ b/doc/topics/configuration.rst Mon Feb 15 19:09:44 2021 +0100
@@ -247,6 +247,10 @@
The path to the certificate.
+.. tip::
+ Set only one of ``privatekey`` or ``certificate`` to ``true`` if the SSL is
+ delegated.
+
email
-----
diff -r 338781cb8e2a -r 6455d1dbf4d5 trytond/url.py
--- a/trytond/url.py Sun Feb 14 15:56:18 2021 +0100
+++ b/trytond/url.py Mon Feb 15 19:09:44 2021 +0100
@@ -27,9 +27,11 @@
context = Transaction().context
if context:
request = context.get('_request')
- if request:
- return request['is_secure']
- return bool(config.get('ssl', 'certificate'))
+ if request and request['is_secure']:
+ return True
+ return bool(
+ config.get('ssl', 'certificate')
+ or config.get('ssl', 'privatekey'))
@classmethod
def host(cls):