Simplify the decryption of container listings
Following https://github.com/openstack/swift/commit/4806434 there is only one handler that might be used. Following https://github.com/openstack/swift/commit/2722e49 all EncryptionException errors should be caught and handled in decrypt_obj_dict. Change-Id: Ib4e9db400a58853daa903ae0a625dfde47747552
This commit is contained in:
@@ -17,6 +17,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from swift import gettext_ as _
|
from swift import gettext_ as _
|
||||||
|
from swift.common.header_key_dict import HeaderKeyDict
|
||||||
from swift.common.http import is_success
|
from swift.common.http import is_success
|
||||||
from swift.common.middleware.crypto.crypto_utils import CryptoWSGIContext, \
|
from swift.common.middleware.crypto.crypto_utils import CryptoWSGIContext, \
|
||||||
load_crypto_meta, extract_crypto_meta, Crypto
|
load_crypto_meta, extract_crypto_meta, Crypto
|
||||||
@@ -353,22 +354,10 @@ class DecrypterContContext(BaseDecrypterContext):
|
|||||||
|
|
||||||
if is_success(self._get_status_int()):
|
if is_success(self._get_status_int()):
|
||||||
# only decrypt body of 2xx responses
|
# only decrypt body of 2xx responses
|
||||||
handler = None
|
headers = HeaderKeyDict(self._response_headers)
|
||||||
for header, value in self._response_headers:
|
content_type = headers.get('content-type', '').split(';', 1)[0]
|
||||||
if header.lower() == 'content-type' and \
|
if content_type == 'application/json':
|
||||||
value.split(';', 1)[0] == 'application/json':
|
app_resp = self.process_json_resp(req, app_resp)
|
||||||
handler = self.process_json_resp
|
|
||||||
|
|
||||||
if handler:
|
|
||||||
try:
|
|
||||||
app_resp = handler(req, app_resp)
|
|
||||||
except EncryptionException as err:
|
|
||||||
self.logger.error(
|
|
||||||
"Error decrypting container listing: %s",
|
|
||||||
err)
|
|
||||||
raise HTTPInternalServerError(
|
|
||||||
body='Error decrypting container listing',
|
|
||||||
content_type='text/plain')
|
|
||||||
|
|
||||||
start_response(self._response_status,
|
start_response(self._response_status,
|
||||||
self._response_headers,
|
self._response_headers,
|
||||||
|
Reference in New Issue
Block a user