def handle_object_get(thisAuth, thisContainer, thisObject): if thisContainer == pseudoContainer.PSEUDO_CONTAINER_NAME: return pseudoContainer.dispatch(thisObject=thisObject) sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=get_token(request)) if sdos_frontend and thisObject.startswith( pseudoObjects.PSEUDO_OBJECT_PREFIX): return pseudoObjects.dispatch_get_head(sdos_frontend, thisObject) myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) s, h, b = httpBackend.doGenericRequest(method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data) if (s == 200 and len(b) and sdos_frontend): try: decrypted_b = sdos_frontend.decrypt_bytes_object(b, thisObject) except: raise HttpError("Decryption failed", 412) # don't overwrite headers since the content length from the original response is incorrect; it accounts for padding... # the Response object will determine the actual, correct size return Response(response=decrypted_b, status=s, headers=strip_etag(h)) else: r = Response(response=b, status=s) # this covers the unencrypted case (1) and also HEAD requests (2). We overwrite ALL the headers to retain # the content size in the HEAD case r.headers = h return r
def handle_account(thisAuth): myUrl = get_proxy_request_url(thisAuth) s, h, b = httpBackend.doGenericRequest(method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data) return Response(response=b, status=s, headers=h)
def handle_container(thisAuth, thisContainer): if thisContainer == pseudoContainer.PSEUDO_CONTAINER_NAME: return "", 200 myUrl = get_proxy_request_url(thisAuth, thisContainer) s, h, b = httpBackend.doGenericRequest(method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data) return Response(response=b, status=s, headers=h)
def handle_object_delete(thisAuth, thisContainer, thisObject): myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) s, h, b = httpBackend.doGenericRequest( method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data ) sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=get_token(request)) if s == 204 and sdos_frontend: sdos_frontend.deleteObject(thisObject, deleteDataObjectInSwift=False) sdos_frontend.finish() return Response(response=b, status=s, headers=h)
def handle_object_delete(thisAuth, thisContainer, thisObject): myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) s, h, b = httpBackend.doGenericRequest(method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data) sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=get_token(request)) if (s == 204 and sdos_frontend): sdos_frontend.deleteObject(thisObject) return Response(response=b, status=s, headers=h)
def handle_object_put(thisAuth, thisContainer, thisObject): myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=get_token(request)) if sdos_frontend and len(request.data): data = sdos_frontend.encrypt_bytes_object(o=request.data, name=thisObject) headers = add_sdos_flag(request.headers) sdos_frontend.finish() else: data = request.data headers = request.headers s, h, b = httpBackend.doGenericRequest( method=request.method, reqUrl=myUrl, reqHead=headers, reqArgs=request.args, reqData=data ) return Response(response=b, status=s, headers=strip_etag(h))
def handle_object_put(thisAuth, thisContainer, thisObject): """ upload/update object; C/U (from CRUD) operations we explicitly check the validity of the request SwiftBackend(tenant=thisAuth, token=thisToken).assert_valid_auth() for pseudo object/pseudo container requests because this otherwise doesn't happen, or happens too late; i.e. after KeyCascade objects were modified. In case of uploads we verify AFTER K.C. operations because the client can just upload the same object again and the "wrongly" assigned key/slot will be re-used :param thisAuth: :param thisContainer: :param thisObject: :return: """ thisToken = get_token(request) if thisContainer == pseudoContainer.PSEUDO_CONTAINER_NAME: SwiftBackend(tenant=thisAuth, token=thisToken).assert_valid_auth() return pseudoContainer.dispatch(thisObject=thisObject, data=request.headers) myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=thisToken) if sdos_frontend and thisObject.startswith( pseudoObjects.PSEUDO_OBJECT_PREFIX): SwiftBackend(tenant=thisAuth, token=thisToken).assert_valid_auth() return pseudoObjects.dispatch_put_post(sdos_frontend, thisObject, request.headers) if (sdos_frontend and len(request.data)): try: data = sdos_frontend.encrypt_bytes_object(o=request.data, name=thisObject) headers = add_sdos_flag(request.headers) except: raise HttpError("Encryption failed", 412) else: data = request.data headers = request.headers s, h, b = httpBackend.doGenericRequest(method=request.method, reqUrl=myUrl, reqHead=headers, reqArgs=request.args, reqData=data) return Response(response=b, status=s, headers=strip_etag(h))
def handle_object_get(thisAuth, thisContainer, thisObject): sdos_frontend = get_sdos_frontend(containerName=thisContainer, swiftTenant=thisAuth, swiftToken=get_token(request)) if sdos_frontend and thisObject.startswith(pseudoObjects.PSEUDO_OBJECT_PREFIX): return pseudoObjects.dispatch(sdos_frontend, thisObject) myUrl = get_proxy_request_url(thisAuth, thisContainer, thisObject) s, h, b = httpBackend.doGenericRequest( method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data ) if s == 200 and len(b) and sdos_frontend: decrypted_b = sdos_frontend.decrypt_bytes_object(b, thisObject) # don't overwrite headers since the content length from the original response is incorrect; it accounts for padding... # the Response object will determine the actual, correct size return Response(response=decrypted_b, status=s, headers=strip_etag(h)) else: r = Response(response=b, status=s) # this covers the unencrypted case (1) and also HEAD requests (2). We overwrite ALL the headers to retain # the content size in the HEAD case r.headers = h return r
def handle_container(thisAuth, thisContainer): myUrl = get_proxy_request_url(thisAuth, thisContainer) s, h, b = httpBackend.doGenericRequest( method=request.method, reqUrl=myUrl, reqHead=request.headers, reqArgs=request.args, reqData=request.data ) return Response(response=b, status=s, headers=h)