Add feature flag to force all direct download URLs to be proxied
Fixes #1667
This commit is contained in:
parent
2b00c644b5
commit
dd2e086a20
12 changed files with 350 additions and 34 deletions
|
@ -3,7 +3,9 @@ from storage.cloud import S3Storage, GoogleCloudStorage, RadosGWStorage
|
|||
from storage.fakestorage import FakeStorage
|
||||
from storage.distributedstorage import DistributedStorage
|
||||
from storage.swift import SwiftStorage
|
||||
from storage.downloadproxy import DownloadProxy
|
||||
|
||||
from urlparse import urlparse, parse_qs
|
||||
|
||||
STORAGE_DRIVER_CLASSES = {
|
||||
'LocalStorage': LocalStorage,
|
||||
|
@ -23,14 +25,14 @@ def get_storage_driver(metric_queue, storage_params):
|
|||
|
||||
|
||||
class Storage(object):
|
||||
def __init__(self, app=None, metric_queue=None):
|
||||
def __init__(self, app=None, metric_queue=None, instance_keys=None):
|
||||
self.app = app
|
||||
if app is not None and metric_queue is not None:
|
||||
self.state = self.init_app(app, metric_queue)
|
||||
if app is not None:
|
||||
self.state = self.init_app(app, metric_queue, instance_keys)
|
||||
else:
|
||||
self.state = None
|
||||
|
||||
def init_app(self, app, metric_queue):
|
||||
def init_app(self, app, metric_queue, instance_keys):
|
||||
storages = {}
|
||||
for location, storage_params in app.config.get('DISTRIBUTED_STORAGE_CONFIG').items():
|
||||
storages[location] = get_storage_driver(metric_queue, storage_params)
|
||||
|
@ -40,7 +42,12 @@ class Storage(object):
|
|||
preference = storages.keys()
|
||||
|
||||
default_locations = app.config.get('DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS') or []
|
||||
d_storage = DistributedStorage(storages, preference, default_locations)
|
||||
|
||||
download_proxy = None
|
||||
if app.config.get('FEATURE_PROXY_STORAGE', False) and instance_keys is not None:
|
||||
download_proxy = DownloadProxy(app, instance_keys)
|
||||
|
||||
d_storage = DistributedStorage(storages, preference, default_locations, download_proxy)
|
||||
|
||||
# register extension with app
|
||||
app.extensions = getattr(app, 'extensions', {})
|
||||
|
|
Reference in a new issue