-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Added tempUrl generating capability #251
base: master
Are you sure you want to change the base?
Conversation
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.
* | ||
* @param string $method An HTTP method to allow for this temporary URL. Any of GET, POST, HEAD, PUT, POST, DELETE. | ||
* @param int $expires Unix timestamp | ||
* @param string $path The full path or storage URL to the Swift object. Example: '/v1/AUTH_account/c/o' or: 'http://saio:8080/v1/AUTH_account/c/o' |
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.
// sha512 requires prefixing signature | ||
$signature = 'sha512' === $digest ? 'sha512:'.$signature : $signature; | ||
|
||
return sprintf('%s?temp_url_sig=%s&temp_url_expires=%s', $path, $signature, $expires); |
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
return sprintf('%s?temp_url_sig=%s&temp_url_expires=%s', $path, $signature, $expires); | |
return sprintf('%s?temp_url_sig=%s&temp_url_expires=%s', urlencode($path), $signature, $expires); |
The function returns the Imagine you have a You rather only want the signature, in order to call: It's especially true if a And |
This method loosely follows swift command's way to generate temporary url:
Some features this PR tries to support: