Fixed temp URL breakage in Swift
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 10 Jan 2014 21:36:13 +0000 (13:36 -0800)
committerOri.livneh <ori@wikimedia.org>
Mon, 13 Jan 2014 19:50:41 +0000 (19:50 +0000)
* The API behavior is not well-documented in that it wants the HMAC
  to use the unencoded object name. CloudFiles had this same issue.

bug: 59894
Change-Id: I3f0c80eed55991bb85d0c12f98927efa19af6760

includes/filebackend/SwiftFileBackend.php

index 91df61b..9ed6a45 100644 (file)
@@ -1136,8 +1136,10 @@ class SwiftFileBackend extends FileBackendStore {
 
                        if ( $this->swiftTempUrlKey != '' ) {
                                $url = $this->storageUrl( $auth, $srcCont, $srcRel );
+                               // Swift wants the signature based on the unencoded object name
+                               $contPath = parse_url( $this->storageUrl( $auth, $srcCont ), PHP_URL_PATH );
                                $signature = hash_hmac( 'sha1',
-                                       "GET\n{$expires}\n" . parse_url( $url, PHP_URL_PATH ),
+                                       "GET\n{$expires}\n{$contPath}/{$srcRel}",
                                        $this->swiftTempUrlKey
                                );
                                return "{$url}?temp_url_sig={$signature}&temp_url_expires={$expires}";