File: Add_tempurl_path_prefix_configuration_option.patch

package info (click to toggle)
swift 2.36.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,024 kB
  • sloc: python: 286,182; javascript: 1,059; sh: 619; pascal: 295; makefile: 81; xml: 32
file content (42 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Description: Add [filter:tempurl]/path_prefix configuration option
 If swiftproxy endpoint is something like /object, with URL rewriting
 by haproxy, then the hmac calculation is wrong.
 .
 This patch adds a new path_prefix directive which is stripped away
 in the URLs before calculating the tempurl hmac.
Author: Kevin Allioli <kevin@linit.io>
Date: Thu, 18 Nov 2021 15:01:45 +0100
Change-Id: I9359feedd93cec482dcd575800e28850c0fc02f3
Forwarded: https://review.opendev.org/c/openstack/swift/+/818388
Last-Update: 2021-11-18

Index: swift/etc/proxy-server.conf-sample
===================================================================
--- swift.orig/etc/proxy-server.conf-sample
+++ swift/etc/proxy-server.conf-sample
@@ -961,6 +961,10 @@ use = egg:swift#tempurl
 # whitespace-delimited.
 # allowed_digests = sha1 sha256 sha512
 
+# Allow to have swiftproxy endpoint not bound to the root with haproxy
+# on-the-fly URL rewriting.
+# path_prefix = /object
+
 # Note: Put formpost just before your auth filter(s) in the pipeline
 [filter:formpost]
 use = egg:swift#formpost
Index: swift/swift/common/middleware/tempurl.py
===================================================================
--- swift.orig/swift/common/middleware/tempurl.py
+++ swift/swift/common/middleware/tempurl.py
@@ -771,6 +771,10 @@ class TempURL(object):
                          to be accessed
         :returns: a list of (hmac, scope) 2-tuples
         """
+
+        if 'path_prefix' in self.conf:
+            path = "/" + self.conf['path_prefix'].strip("/") + path
+
         if not request_method:
             request_method = env['REQUEST_METHOD']