#179: Invalid Shared Access Signature URL's.
This commit is contained in:
Родитель
e1625f3c3f
Коммит
1a0960725c
|
@ -2166,8 +2166,8 @@ BlobService.prototype.listBlobBlocks = function (container, blob, blocklisttype,
|
|||
* @param {object} sharedAccessPolicy The shared access policy.
|
||||
* @param {string} [sharedAccessPolicy.Id] The signed identifier.
|
||||
* @param {SharedAccessPermissions} sharedAccessPolicy.AccessPolicy.Permissions The permission type.
|
||||
* @param {date} [sharedAccessPolicy.AccessPolicy.Start] The time at which the Shared Access Signature becomes valid (The UTC value will be used).
|
||||
* @param {date} sharedAccessPolicy.AccessPolicy.Expiry The time at which the Shared Access Signature becomes expired (The UTC value will be used).
|
||||
* @param {date|string} [sharedAccessPolicy.AccessPolicy.Start] The time at which the Shared Access Signature becomes valid (The UTC value will be used).
|
||||
* @param {date|string} sharedAccessPolicy.AccessPolicy.Expiry The time at which the Shared Access Signature becomes expired (The UTC value will be used).
|
||||
* @return {object} An object with the shared access signature.
|
||||
*/
|
||||
BlobService.prototype.generateSharedAccessSignature = function (container, blob, sharedAccessPolicy) {
|
||||
|
@ -2180,11 +2180,11 @@ BlobService.prototype.generateSharedAccessSignature = function (container, blob,
|
|||
}
|
||||
|
||||
if (!azureutil.objectIsNull(sharedAccessPolicy.AccessPolicy.Start)) {
|
||||
sharedAccessPolicy.AccessPolicy.Start = ISO8061Date.format(sharedAccessPolicy.AccessPolicy.Start);
|
||||
sharedAccessPolicy.AccessPolicy.Start = ISO8061Date.format(sharedAccessPolicy.AccessPolicy.Start, true);
|
||||
}
|
||||
|
||||
if (!azureutil.objectIsNull(sharedAccessPolicy.AccessPolicy.Expiry)) {
|
||||
sharedAccessPolicy.AccessPolicy.Expiry = ISO8061Date.format(sharedAccessPolicy.AccessPolicy.Expiry);
|
||||
sharedAccessPolicy.AccessPolicy.Expiry = ISO8061Date.format(sharedAccessPolicy.AccessPolicy.Expiry, true);
|
||||
}
|
||||
|
||||
var resourceName = createResourceName(container, blob);
|
||||
|
|
|
@ -17,25 +17,43 @@
|
|||
* Formats a date into an iso 8061 string.
|
||||
*
|
||||
* @param {date} date The date to format.
|
||||
* @param {bool} skipMilliseconds Boolean value indicating if the miliseconds part of the date should not be included.
|
||||
* @return {string} The date formated in the ISO 8061 date format.
|
||||
*/
|
||||
exports.format = function (date) {
|
||||
return [
|
||||
date.getUTCFullYear(),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCMonth() + 1),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCDate()),
|
||||
'T',
|
||||
leftPadTwo(date.getUTCHours()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCMinutes()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCSeconds()),
|
||||
'.',
|
||||
leftPadThree(date.getUTCMilliseconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
exports.format = function (date, skipMilliseconds) {
|
||||
if (!skipMilliseconds) {
|
||||
return [
|
||||
date.getUTCFullYear(),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCMonth() + 1),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCDate()),
|
||||
'T',
|
||||
leftPadTwo(date.getUTCHours()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCMinutes()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCSeconds()),
|
||||
'.',
|
||||
leftPadThree(date.getUTCMilliseconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
} else {
|
||||
return [
|
||||
date.getUTCFullYear(),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCMonth() + 1),
|
||||
'-',
|
||||
leftPadTwo(date.getUTCDate()),
|
||||
'T',
|
||||
leftPadTwo(date.getUTCHours()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCMinutes()),
|
||||
':',
|
||||
leftPadTwo(date.getUTCSeconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,6 +72,27 @@ suite('sharedaccesssignature-tests', function () {
|
|||
done();
|
||||
});
|
||||
|
||||
test('GenerateSignatureBlobDate', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
// Using date with milliseconds defined to make sure they are ignored in the signature
|
||||
var sharedAccessPolicy = {
|
||||
AccessPolicy: {
|
||||
Permissions: BlobConstants.SharedAccessPermissions.READ,
|
||||
Start: new Date(2011, 10, 11, 11, 03, 40, 100),
|
||||
Expiry: new Date(2011, 10, 12, 11, 03, 40, 100)
|
||||
}
|
||||
};
|
||||
|
||||
var signature = credentials._generateSignature(
|
||||
'images/pic1.png',
|
||||
BlobConstants.ResourceTypes.BLOB,
|
||||
sharedAccessPolicy);
|
||||
|
||||
assert.equal(signature, '7NIEip+VOrQ5ZV80pORPK1MOsJc62wwCNcbMvE+lQ0s=');
|
||||
done();
|
||||
});
|
||||
|
||||
test('ContainerSignedQueryString', function (done) {
|
||||
var credentials = new SharedAccessSignature(ServiceClient.DEVSTORE_STORAGE_ACCOUNT, ServiceClient.DEVSTORE_STORAGE_ACCESS_KEY);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче