|
|
e9bfca |
From 2b4bacf2efa04c18a6ab576e30594a8742e45bf7 Mon Sep 17 00:00:00 2001
|
|
|
e9bfca |
From: Nir Soffer <nirsof@gmail.com>
|
|
|
e9bfca |
Date: Fri, 29 Jun 2018 17:41:10 +0300
|
|
|
e9bfca |
Subject: [PATCH] v2v: rhv-upload-plugin: Remove unneeded auth
|
|
|
e9bfca |
|
|
|
e9bfca |
Old imageio proxy was using Authorization header for GET and PUT
|
|
|
e9bfca |
requests. Remove unneeded authorization when sending OPTIONS request.
|
|
|
e9bfca |
|
|
|
e9bfca |
Remove unneeded duplicated comments about authorization for old
|
|
|
e9bfca |
imageio, and replace them with a comment when we set needs_auth.
|
|
|
e9bfca |
|
|
|
e9bfca |
(cherry picked from commit d5f36bacf9bb6d4d244184551792989906f60896)
|
|
|
e9bfca |
---
|
|
|
e9bfca |
v2v/rhv-upload-plugin.py | 12 +++++-------
|
|
|
e9bfca |
1 file changed, 5 insertions(+), 7 deletions(-)
|
|
|
e9bfca |
|
|
|
e9bfca |
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
|
|
|
e9bfca |
index 8805e3552..f404bd758 100644
|
|
|
e9bfca |
--- a/v2v/rhv-upload-plugin.py
|
|
|
e9bfca |
+++ b/v2v/rhv-upload-plugin.py
|
|
|
e9bfca |
@@ -191,16 +191,17 @@ def open(readonly):
|
|
|
e9bfca |
)
|
|
|
e9bfca |
|
|
|
e9bfca |
# The first request is to fetch the features of the server.
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ # Authentication was needed only for GET and PUT requests when
|
|
|
e9bfca |
+ # communicating with old imageio-proxy.
|
|
|
e9bfca |
needs_auth = not params['rhv_direct']
|
|
|
e9bfca |
+
|
|
|
e9bfca |
can_flush = False
|
|
|
e9bfca |
can_trim = False
|
|
|
e9bfca |
can_zero = False
|
|
|
e9bfca |
unix_socket = None
|
|
|
e9bfca |
|
|
|
e9bfca |
- http.putrequest("OPTIONS", destination_url.path)
|
|
|
e9bfca |
- http.putheader("Authorization", transfer.signed_ticket)
|
|
|
e9bfca |
- http.endheaders()
|
|
|
e9bfca |
-
|
|
|
e9bfca |
+ http.request("OPTIONS", destination_url.path)
|
|
|
e9bfca |
r = http.getresponse()
|
|
|
e9bfca |
data = r.read()
|
|
|
e9bfca |
|
|
|
e9bfca |
@@ -298,7 +299,6 @@ def pread(h, count, offset):
|
|
|
e9bfca |
transfer = h['transfer']
|
|
|
e9bfca |
|
|
|
e9bfca |
headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)}
|
|
|
e9bfca |
- # Authorization is only needed for old imageio.
|
|
|
e9bfca |
if h['needs_auth']:
|
|
|
e9bfca |
headers["Authorization"] = transfer.signed_ticket
|
|
|
e9bfca |
|
|
|
e9bfca |
@@ -321,7 +321,6 @@ def pwrite(h, buf, offset):
|
|
|
e9bfca |
h['highestwrite'] = max(h['highestwrite'], offset+count)
|
|
|
e9bfca |
|
|
|
e9bfca |
http.putrequest("PUT", h['path'] + "?flush=n")
|
|
|
e9bfca |
- # Authorization is only needed for old imageio.
|
|
|
e9bfca |
if h['needs_auth']:
|
|
|
e9bfca |
http.putheader("Authorization", transfer.signed_ticket)
|
|
|
e9bfca |
# The oVirt server only uses the first part of the range, and the
|
|
|
e9bfca |
@@ -378,7 +377,6 @@ def emulate_zero(h, count, offset):
|
|
|
e9bfca |
# After that we must emulate them with writes.
|
|
|
e9bfca |
if offset+count < h['highestwrite']:
|
|
|
e9bfca |
http.putrequest("PUT", h['path'])
|
|
|
e9bfca |
- # Authorization is only needed for old imageio.
|
|
|
e9bfca |
if h['needs_auth']:
|
|
|
e9bfca |
http.putheader("Authorization", transfer.signed_ticket)
|
|
|
e9bfca |
http.putheader("Content-Range",
|
|
|
e9bfca |
--
|
|
|
3d5c2a |
2.17.2
|
|
|
e9bfca |
|