-
Notifications
You must be signed in to change notification settings - Fork 158
Comments
Conversation
67c32b2 to
6983012
Compare
@MSC29
MSC29
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently used this code & stumbled upon a issue when using container objects with spaces in their name...
The hash used the non-encoded path but the temporary url queried agaisnt openstack needs to be url encoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there. I just re-used this code as I need to generate temporary urls.
It took me a while to notice the issue but here it is in the doc "Do not URL-encode the path when you generate the HMAC-SHA1 signature. However, when you make the actual HTTP request, you should properly URL-encode the URL.".
I'd add this to the doc to ensure an non-encoded $path is passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the $path is not encoded, I'd suggest encoding the actual temporary url path
The function returns the signature (what is needed from this function) bundled with $expires and $path (callers just passed as arguments).
Imagine you have a Psr\Http\Message\UriInterface (as obtained by by$container->getObject('')->getPublicUri();)
You rather only want the signature, in order to call:
$uri->withQuery(sprintf('temp_url_sig=%s&temp_url_expires=%s', $signature, $expires))->__toString();
It's especially true if a prefix is used because the prefix:<path> format expected for hash-generation is not a path suitable for actual Uri building.
I think the function should just return the $signature (string)
And urlencode() would be up to the caller.
Uh oh!
There was an error while loading. Please reload this page.
This method loosely follows swift command's way to generate temporary url:
Some features this PR tries to support: