From f4f51934efd6136203dc261b9ead782105a239b6 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 10 Jan 2018 13:16:41 -0500 Subject: [PATCH 1/2] Linter fixes for cloudfront storage --- storage/cloud.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/storage/cloud.py b/storage/cloud.py index e2f1c1171..a04f50ed6 100644 --- a/storage/cloud.py +++ b/storage/cloud.py @@ -619,7 +619,7 @@ class CloudFrontedS3Storage(S3Storage): return super(CloudFrontedS3Storage, self).get_direct_download_url(path, request_ip, expires_in, requires_cors, head) - + resolved_ip_info = None logger.debug('Got direct download request for path "%s" with IP "%s"', path, request_ip) if request_ip is not None: @@ -651,7 +651,7 @@ class CloudFrontedS3Storage(S3Storage): signer = private_key.signer(padding.PKCS1v15(), hashes.SHA1()) signer.update(message) return signer.finalize() - + return handler @lru_cache(maxsize=1) @@ -663,8 +663,8 @@ class CloudFrontedS3Storage(S3Storage): return None with self._context.config_provider.get_volume_file(cloudfront_privatekey_filename) as key_file: - return serialization.load_pem_private_key( - key_file.read(), - password=None, - backend=default_backend() - ) + return serialization.load_pem_private_key( + key_file.read(), + password=None, + backend=default_backend() + ) From b0f656731cb3799bc47cf0b6f97d08db2ee1f5a9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 10 Jan 2018 14:46:36 -0500 Subject: [PATCH 2/2] Add support for configuring CloudFront storage engine Fixes https://jira.coreos.com/browse/QS-116 --- endpoints/api/suconfig.py | 8 ++--- .../directives/config/config-setup-tool.html | 8 ++++- static/js/core-config-setup.js | 31 ++++++++++++++---- util/config/test/test_validator.py | 32 +++++++++++++++++++ util/config/validator.py | 11 +++++++ 5 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 util/config/test/test_validator.py diff --git a/endpoints/api/suconfig.py b/endpoints/api/suconfig.py index c2fca2502..66f241670 100644 --- a/endpoints/api/suconfig.py +++ b/endpoints/api/suconfig.py @@ -20,7 +20,7 @@ from endpoints.api import (ApiResource, nickname, resource, internal_only, show_ from endpoints.common import common_login from util.config.configutil import add_enterprise_config_defaults from util.config.database import sync_database_with_config -from util.config.validator import validate_service_for_config, CONFIG_FILENAMES +from util.config.validator import validate_service_for_config, is_valid_config_upload_filename from util.license import decode_license, LicenseDecodeError import features @@ -319,12 +319,12 @@ class SuperUserConfigFile(ApiResource): @verify_not_prod def get(self, filename): """ Returns whether the configuration file with the given name exists. """ - if not filename in CONFIG_FILENAMES: + if not is_valid_config_upload_filename(filename): abort(404) if SuperUserPermission().can(): return { - 'exists': config_provider.volume_file_exists(filename) + 'exists': config_provider.volume_file_exists(filename) } abort(403) @@ -333,7 +333,7 @@ class SuperUserConfigFile(ApiResource): @verify_not_prod def post(self, filename): """ Updates the configuration file with the given name. """ - if not filename in CONFIG_FILENAMES: + if not is_valid_config_upload_filename(filename): abort(404) # Note: This method can be called before the configuration exists diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index c7ad5d71e..c67e839c6 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -300,6 +300,7 @@ +
@@ -327,6 +328,11 @@ ng-if="field.kind == 'bool'"> {{ field.placeholder }} +