customers cannot change sas version anymore (#957)

This commit is contained in:
JinmingHu 2020-11-12 16:29:24 +08:00 committed by GitHub
parent 3838944ab9
commit 43cc2e547c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 50 deletions

View File

@ -177,13 +177,6 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
struct BlobSasBuilder
{
/**
* @brief The storage service version to use to authenticate requests made with this
* shared access signature, and the service version to use when handling requests made with this
* shared access signature.
*/
std::string Version = Storage::Details::c_defaultSasVersion;
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.

View File

@ -130,15 +130,17 @@ namespace Azure { namespace Storage { namespace Blobs {
std::string stringToSign = Permissions + "\n" + (StartsOn.HasValue() ? StartsOn.GetValue() : "")
+ "\n" + ExpiresOn + "\n" + canonicalName + "\n" + Identifier + "\n"
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n" + Version + "\n"
+ resource + "\n" + snapshotVersion + "\n" + CacheControl + "\n" + ContentDisposition + "\n"
+ ContentEncoding + "\n" + ContentLanguage + "\n" + ContentType;
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Storage::Details::c_defaultSasVersion + "\n" + resource + "\n" + snapshotVersion + "\n"
+ CacheControl + "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage
+ "\n" + ContentType;
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Storage::Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Storage::Details::UrlEncodeQueryParameter(Storage::Details::c_defaultSasVersion));
builder.AppendQueryParameter("spr", Storage::Details::UrlEncodeQueryParameter(protocol));
if (StartsOn.HasValue())
{
@ -219,15 +221,17 @@ namespace Azure { namespace Storage { namespace Blobs {
+ userDelegationKey.SignedTenantId + "\n" + userDelegationKey.SignedStartsOn + "\n"
+ userDelegationKey.SignedExpiresOn + "\n" + userDelegationKey.SignedService + "\n"
+ userDelegationKey.SignedVersion + "\n\n\n\n"
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n" + Version + "\n"
+ resource + "\n" + snapshotVersion + "\n" + CacheControl + "\n" + ContentDisposition + "\n"
+ ContentEncoding + "\n" + ContentLanguage + "\n" + ContentType;
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Storage::Details::c_defaultSasVersion + "\n" + resource + "\n" + snapshotVersion + "\n"
+ CacheControl + "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage
+ "\n" + ContentType;
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(userDelegationKey.Value)));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Storage::Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Storage::Details::UrlEncodeQueryParameter(Storage::Details::c_defaultSasVersion));
builder.AppendQueryParameter("sr", Storage::Details::UrlEncodeQueryParameter(resource));
if (StartsOn.HasValue())
{

View File

@ -202,13 +202,6 @@ namespace Azure { namespace Storage {
*/
struct AccountSasBuilder
{
/**
* @brief The storage service version to use to authenticate requests made with this
* shared access signature, and the service version to use when handling requests made with this
* shared access signature.
*/
std::string Version = Details::c_defaultSasVersion;
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.

View File

@ -98,14 +98,15 @@ namespace Azure { namespace Storage {
std::string stringToSign = credential.AccountName + "\n" + Permissions + "\n" + services + "\n"
+ resourceTypes + "\n" + (StartsOn.HasValue() ? StartsOn.GetValue() : "") + "\n" + ExpiresOn
+ "\n" + (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n" + Version
+ "\n";
+ "\n" + (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Details::c_defaultSasVersion + "\n";
std::string signature
= Base64Encode(Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Details::UrlEncodeQueryParameter(Details::c_defaultSasVersion));
builder.AppendQueryParameter("ss", Details::UrlEncodeQueryParameter(services));
builder.AppendQueryParameter("srt", Details::UrlEncodeQueryParameter(resourceTypes));
builder.AppendQueryParameter("sp", Details::UrlEncodeQueryParameter(Permissions));

View File

@ -178,13 +178,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
struct DataLakeSasBuilder
{
/**
* @brief The storage service version to use to authenticate requests made with this
* shared access signature, and the service version to use when handling requests made with this
* shared access signature.
*/
std::string Version = Storage::Details::c_defaultSasVersion;
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.

View File

@ -125,15 +125,17 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
std::string stringToSign = Permissions + "\n" + (StartsOn.HasValue() ? StartsOn.GetValue() : "")
+ "\n" + ExpiresOn + "\n" + canonicalName + "\n" + Identifier + "\n"
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n" + Version + "\n"
+ resource + "\n" + "\n" + CacheControl + "\n" + ContentDisposition + "\n" + ContentEncoding
+ "\n" + ContentLanguage + "\n" + ContentType;
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Storage::Details::c_defaultSasVersion + "\n" + resource + "\n" + "\n" + CacheControl
+ "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage + "\n"
+ ContentType;
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Storage::Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Storage::Details::UrlEncodeQueryParameter(Storage::Details::c_defaultSasVersion));
builder.AppendQueryParameter("spr", Storage::Details::UrlEncodeQueryParameter(protocol));
if (StartsOn.HasValue())
{
@ -204,14 +206,16 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
+ userDelegationKey.SignedExpiresOn + "\n" + userDelegationKey.SignedService + "\n"
+ userDelegationKey.SignedVersion + "\n" + PreauthorizedAgentObjectId + "\n" + AgentObjectId
+ "\n" + CorrelationId + "\n" + (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n"
+ protocol + "\n" + Version + "\n" + resource + "\n" + "\n" + CacheControl + "\n"
+ ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage + "\n" + ContentType;
+ protocol + "\n" + Storage::Details::c_defaultSasVersion + "\n" + resource + "\n" + "\n"
+ CacheControl + "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage
+ "\n" + ContentType;
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(userDelegationKey.Value)));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Storage::Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Storage::Details::UrlEncodeQueryParameter(Storage::Details::c_defaultSasVersion));
builder.AppendQueryParameter("sr", Storage::Details::UrlEncodeQueryParameter(resource));
if (StartsOn.HasValue())
{

View File

@ -128,13 +128,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*/
struct ShareSasBuilder
{
/**
* @brief The storage service version to use to authenticate requests made with this
* shared access signature, and the service version to use when handling requests made with this
* shared access signature.
*/
std::string Version = Azure::Storage::Details::c_defaultSasVersion;
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.

View File

@ -86,15 +86,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::string stringToSign = Permissions + "\n" + (StartsOn.HasValue() ? StartsOn.GetValue() : "")
+ "\n" + ExpiresOn + "\n" + canonicalName + "\n" + Identifier + "\n"
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n" + Version + "\n"
+ CacheControl + "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage
+ "\n" + ContentType;
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Details::c_defaultSasVersion + "\n" + CacheControl + "\n" + ContentDisposition + "\n"
+ ContentEncoding + "\n" + ContentLanguage + "\n" + ContentType;
std::string signature
= Base64Encode(Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter("sv", Details::UrlEncodeQueryParameter(Version));
builder.AppendQueryParameter(
"sv", Details::UrlEncodeQueryParameter(Details::c_defaultSasVersion));
builder.AppendQueryParameter("spr", Details::UrlEncodeQueryParameter(protocol));
if (StartsOn.HasValue())
{