From 3a3b3c3269fef11ea2fa8273d998489157cae8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 1 Sep 2017 16:19:58 +0200 Subject: [PATCH] Revert "Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting." This reverts commit 8318d4b1f69846e21002acafd4f410f5003af6f6. --- pillar/api/file_storage/__init__.py | 3 ++- pillar/api/file_storage_backends/local.py | 5 +++-- pillar/auth/oauth.py | 3 ++- pillar/config.py | 2 +- pillar/web/nodes/routes.py | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pillar/api/file_storage/__init__.py b/pillar/api/file_storage/__init__.py index d5877ddc..e94b563b 100644 --- a/pillar/api/file_storage/__init__.py +++ b/pillar/api/file_storage/__init__.py @@ -364,7 +364,8 @@ def generate_link(backend, file_path: str, project_id=None, is_public=False) -> return blob.get_url(is_public=is_public) if backend == 'pillar': - return url_for('file_storage.index', file_name=file_path, _external=True) + return url_for('file_storage.index', file_name=file_path, + _external=True, _scheme=current_app.config['SCHEME']) if backend == 'cdnsun': return hash_file_path(file_path, None) if backend == 'unittest': diff --git a/pillar/api/file_storage_backends/local.py b/pillar/api/file_storage_backends/local.py index c1147d63..40049770 100644 --- a/pillar/api/file_storage_backends/local.py +++ b/pillar/api/file_storage_backends/local.py @@ -34,7 +34,7 @@ class LocalBucket(Bucket): def copy_blob(self, blob: Blob, to_bucket: Bucket): """Copies a blob from the current bucket to the other bucket. - + Implementations only need to support copying between buckets of the same storage backend. """ @@ -73,7 +73,8 @@ class LocalBlob(Blob): from flask import url_for path = self.bucket.bucket_path / self.partial_path - url = url_for('file_storage.index', file_name=str(path), _external=True) + url = url_for('file_storage.index', file_name=str(path), _external=True, + _scheme=current_app.config['SCHEME']) return url def create_from_file(self, file_obj: FileType, *, diff --git a/pillar/auth/oauth.py b/pillar/auth/oauth.py index ab420130..a01c6a11 100644 --- a/pillar/auth/oauth.py +++ b/pillar/auth/oauth.py @@ -74,7 +74,8 @@ class OAuthSignIn(metaclass=abc.ABCMeta): pass def get_callback_url(self): - return url_for('users.oauth_callback', provider=self.provider_name, _external=True) + return url_for('users.oauth_callback', provider=self.provider_name, + _external=True, _scheme=current_app.config['SCHEME']) @staticmethod def auth_code_from_request() -> str: diff --git a/pillar/config.py b/pillar/config.py index 30658560..1b2ae20f 100644 --- a/pillar/config.py +++ b/pillar/config.py @@ -12,7 +12,7 @@ import requests.certs RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' PILLAR_SERVER_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -PREFERRED_URL_SCHEME = 'https' +SCHEME = 'https' STORAGE_DIR = getenv('PILLAR_STORAGE_DIR', '/data/storage/pillar') PORT = 5000 HOST = '0.0.0.0' diff --git a/pillar/web/nodes/routes.py b/pillar/web/nodes/routes.py index 9bcd757a..2b997bbc 100644 --- a/pillar/web/nodes/routes.py +++ b/pillar/web/nodes/routes.py @@ -412,7 +412,8 @@ def edit(node_id): else: project_update_nodes_list(node, project_id=project._id) return redirect(url_for('nodes.view', node_id=node_id, embed=1, - _external=True)) + _external=True, + _scheme=current_app.config['SCHEME'])) else: log.debug('Error sending data to Pillar, see Pillar logs.') error = 'Server error'