Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #694 from erezvani1529/master
Browse files Browse the repository at this point in the history
[9.2][Nov17] Release
  • Loading branch information
zezha-msft authored May 22, 2018
2 parents 3331c60 + 4dad44d commit a9841c9
Show file tree
Hide file tree
Showing 65 changed files with 1,096 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public static class EncryptionConstants
public const string TableEncryptionKeyDetails = "_ClientEncryptionMetadata1";
public const string TableEncryptionPropertyDetails = "_ClientEncryptionMetadata2";
public const string AgentMetadataKey = "EncryptionLibrary";
public const string AgentMetadataValue = ".NET 9.1.1";
public const string AgentMetadataValue = ".NET 9.2.0";

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class EncryptionConstants
public const string TableEncryptionKeyDetails = "_ClientEncryptionMetadata1";
public const string TableEncryptionPropertyDetails = "_ClientEncryptionMetadata2";
public const string AgentMetadataKey = "EncryptionLibrary";
public const string AgentMetadataValue = ".NET 9.1.1";
public const string AgentMetadataValue = ".NET 9.2.0";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol

public static class HeaderConstants
{
public static readonly string UserAgent = "Azure-Storage/9.1.1 ";
public static readonly string UserAgent = "Azure-Storage/9.2.0 ";
public const string UserAgentProductName = "Azure-Storage";
public const string UserAgentProductVersion = "9.1.1";
public const string UserAgentProductVersion = "9.2.0";
public const string PrefixForStorageHeader = "x-ms-";
public const string TrueHeader = "true";
public const string FalseHeader = "false";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("9.1.1.0")]
[assembly: AssemblyFileVersion("9.1.1.0")]
[assembly: AssemblyVersion("9.2.0.0")]
[assembly: AssemblyFileVersion("9.2.0.0")]

[assembly: InternalsVisibleTo(
"Microsoft.WindowsAzure.Storage.Facade.Portable, PublicKey=" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Microsoft.WindowsAzure.Storage",
"version": "9.1.1.0",
"version": "9.2.0.0",

"authors": [ "Microsoft Corporation" ],
"description": "Azure Storage SDK for NetCore",
Expand Down
6 changes: 3 additions & 3 deletions Lib/AspNet/Microsoft.WindowsAzure.Storage/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("9.1.1.0")]
[assembly: AssemblyFileVersion("9.1.1.0")]
[assembly: AssemblyInformationalVersion("9.1.1.0")]
[assembly: AssemblyVersion("9.2.0.0")]
[assembly: AssemblyFileVersion("9.2.0.0")]
[assembly: AssemblyInformationalVersion("9.2.0.0")]


[assembly: InternalsVisibleTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>WindowsAzure.Storage</id>
<version>9.1.1</version>
<version>9.2.0</version>
<title>Windows Azure Storage</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand Down
2 changes: 1 addition & 1 deletion Lib/AspNet/Microsoft.WindowsAzure.Storage/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "9.1.1.0",
"version": "9.2.0.0",

"authors": [ "Microsoft Corporation" ],
"description": "Azure Storage SDK for NetCore",
Expand Down
77 changes: 77 additions & 0 deletions Lib/ClassLibraryCommon/Auth/Protocol/TokenAuthenticationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//-----------------------------------------------------------------------
// <copyright file="TokenAuthenticationHandler.cs" company="Microsoft">
// Copyright 2013 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.WindowsAzure.Storage.Auth.Protocol
{
using Microsoft.WindowsAzure.Storage.Core;
using Microsoft.WindowsAzure.Storage.Core.Auth;
using Microsoft.WindowsAzure.Storage.Core.Util;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Net;

/// <summary>
/// Represents a handler that signs HTTPS requests with a token.
/// </summary>
internal sealed class TokenAuthenticationHandler : IAuthenticationHandler
{
private readonly StorageCredentials credentials;

/// <summary>
/// Initializes a new instance of the <see cref="TokenAuthenticationHandler"/> class.
/// </summary>
/// <param name="credentials">A <see cref="StorageCredentials"/> object providing credentials for the request.</param>
public TokenAuthenticationHandler(StorageCredentials credentials)
{
this.credentials = credentials;
}

/// <summary>
/// Signs the specified HTTPS request with a token.
/// </summary>
/// <param name="request">The HTTPS request to sign.</param>
/// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
public void SignRequest(HttpWebRequest request, OperationContext operationContext)
{
CommonUtility.AssertNotNull("request", request);

// only HTTPS is allowed for token credential, as the token would be at risk of being intercepted with HTTP.
#if !WINDOWS_PHONE
if (!"https".Equals(request.Address.Scheme, StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException(SR.OnlyHttpsIsSupportedForTokenCredential);
}
#endif

if (!request.Headers.AllKeys.Contains(Constants.HeaderConstants.Date, StringComparer.Ordinal))
{
string dateString = HttpWebUtility.ConvertDateTimeToHttpString(DateTime.UtcNow);
request.Headers.Add(Constants.HeaderConstants.Date, dateString);
}

if (this.credentials.IsToken)
{
request.Headers.Add(
"Authorization",
string.Format(CultureInfo.InvariantCulture, "Bearer {0}", this.credentials.TokenCredential.Token));
}
}
}
}
1 change: 1 addition & 0 deletions Lib/ClassLibraryCommon/Blob/CloudBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4184,6 +4184,7 @@ internal static void UpdateETagLMTLengthAndSequenceNumber(BlobAttributes blobAtt
{
BlobProperties parsedProperties = BlobHttpResponseParsers.GetProperties(response);
blobAttributes.Properties.ETag = parsedProperties.ETag ?? blobAttributes.Properties.ETag;
blobAttributes.Properties.Created = parsedProperties.Created ?? blobAttributes.Properties.Created;
blobAttributes.Properties.LastModified = parsedProperties.LastModified ?? blobAttributes.Properties.LastModified;
blobAttributes.Properties.PageBlobSequenceNumber = parsedProperties.PageBlobSequenceNumber ?? blobAttributes.Properties.PageBlobSequenceNumber;
blobAttributes.Properties.AppendBlobCommittedBlockCount = parsedProperties.AppendBlobCommittedBlockCount ?? blobAttributes.Properties.AppendBlobCommittedBlockCount;
Expand Down
4 changes: 4 additions & 0 deletions Lib/ClassLibraryCommon/Blob/CloudBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ internal IAuthenticationHandler AuthenticationHandler
this.Credentials,
this.Credentials.AccountName);
}
else if (this.Credentials.IsToken)
{
result = new TokenAuthenticationHandler(this.Credentials);
}
else
{
result = new NoOpAuthenticationHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ public static BlobProperties GetProperties(HttpWebResponse response)
properties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
properties.Created = HttpResponseParsers.GetCreated(response);
properties.LastModified = HttpResponseParsers.GetLastModified(response);
properties.ContentLanguage = response.Headers[Constants.HeaderConstants.ContentLanguageHeader];
#else
string created = response.Headers[Constants.HeaderConstants.CreationTimeHeader];
properties.Created = string.IsNullOrEmpty(created) ? (DateTimeOffset?)null : DateTimeOffset.Parse(created).ToUniversalTime();

properties.LastModified = response.LastModified.ToUniversalTime();
properties.ContentLanguage = response.Headers[HttpResponseHeader.ContentLanguage];
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Storage.Blob.Protocol
using Microsoft.WindowsAzure.Storage.Core.Util;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
using System.Collections.Generic;
using System.Globalization;
using System.Net;

/// <summary>
Expand Down Expand Up @@ -60,8 +61,17 @@ public static BlobContainerProperties GetProperties(HttpWebResponse response)
containerProperties.LeaseStatus = BlobHttpResponseParsers.GetLeaseStatus(response);
containerProperties.LeaseState = BlobHttpResponseParsers.GetLeaseState(response);
containerProperties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(response);

// Reading public access
containerProperties.PublicAccess = GetAcl(response);

// WORM policies
string hasImmutability = response.Headers[Constants.HeaderConstants.HasImmutabilityPolicyHeader];
containerProperties.HasImmutabilityPolicy = string.IsNullOrEmpty(hasImmutability) ? (bool?)null : bool.Parse(hasImmutability);

string hasLegalHold = response.Headers[Constants.HeaderConstants.HasLegalHoldHeader];
containerProperties.HasLegalHold = string.IsNullOrEmpty(hasLegalHold) ? (bool?)null : bool.Parse(hasLegalHold);

return containerProperties;
}

Expand Down
4 changes: 4 additions & 0 deletions Lib/ClassLibraryCommon/File/CloudFileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ internal IAuthenticationHandler AuthenticationHandler
this.Credentials,
this.Credentials.AccountName);
}
else if (this.Credentials.IsToken)
{
throw new InvalidOperationException(SR.TokenIsNotSupportedForThisService);
}
else
{
result = new NoOpAuthenticationHandler();
Expand Down
4 changes: 4 additions & 0 deletions Lib/ClassLibraryCommon/Queue/CloudQueueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ internal IAuthenticationHandler AuthenticationHandler
this.Credentials,
this.Credentials.AccountName);
}
else if (this.Credentials.IsToken)
{
result = new TokenAuthenticationHandler(this.Credentials);
}
else
{
result = new NoOpAuthenticationHandler();
Expand Down
11 changes: 11 additions & 0 deletions Lib/ClassLibraryCommon/Shared/Protocol/HttpResponseParsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ internal static string GetETag(HttpWebResponse response)
}

#if WINDOWS_PHONE
/// <summary>
/// Gets the Creation-Time date and time from a response.
/// </summary>
/// <param name="response">The web response.</param>
/// <returns>A <see cref="System.DateTimeOffset"/> that indicates the creation date and time.</returns>
internal static DateTimeOffset? GetCreated(HttpWebResponse response)
{
string created = response.Headers[Constants.HeaderConstants.CreationTimeHeader];
return string.IsNullOrEmpty(created) ? (DateTimeOffset?)null : DateTimeOffset.Parse(created, CultureInfo.InvariantCulture);
}

/// <summary>
/// Gets the Last-Modified date and time from a response.
/// </summary>
Expand Down
14 changes: 9 additions & 5 deletions Lib/ClassLibraryCommon/Shared/Protocol/HttpWebRequestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ internal static HttpWebRequest CreateWebRequest(string method, Uri uri, int? tim
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uriRequest);
request.Method = method;

// Set the Content-Length of requests to 0 by default for all put requests.
if (method.Equals(WebRequestMethods.Http.Put, StringComparison.OrdinalIgnoreCase))
{
request.ContentLength = 0;
}
#if !WINDOWS_PHONE
request.Proxy = operationContext.Proxy ?? request.Proxy;
#endif

// Set the Content-Length of requests to 0 by default for all put requests.
if (method.Equals(WebRequestMethods.Http.Put, StringComparison.OrdinalIgnoreCase))
{
request.ContentLength = 0;
}

request.UserAgent = Constants.HeaderConstants.UserAgent;

Expand Down
4 changes: 4 additions & 0 deletions Lib/ClassLibraryCommon/Table/CloudTableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ internal IAuthenticationHandler AuthenticationHandler
this.Credentials,
this.Credentials.AccountName);
}
else if (this.Credentials.IsToken)
{
throw new InvalidOperationException(SR.TokenIsNotSupportedForThisService);
}
else
{
result = new NoOpAuthenticationHandler();
Expand Down
37 changes: 35 additions & 2 deletions Lib/Common/Auth/StorageCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Microsoft.WindowsAzure.Storage.Auth
using Microsoft.WindowsAzure.Storage.Core;
using Microsoft.WindowsAzure.Storage.Core.Util;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
using Microsoft.WindowsAzure.Storage.Auth;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
Expand Down Expand Up @@ -66,6 +67,11 @@ public string KeyName
}
}

/// <summary>
/// Gets the associated OAuth Token for the credentials.
/// </summary>
internal TokenCredential TokenCredential { get; private set; }

internal StorageAccountKey Key { get; private set; }

/// <summary>
Expand Down Expand Up @@ -101,7 +107,19 @@ public bool IsSharedKey
{
get
{
return (this.SASToken == null) && (this.AccountName != null);
return (this.SASToken == null) && (this.TokenCredential == null) && (this.AccountName != null);
}
}

/// <summary>
/// Gets a value indicating whether the credentials are a bearer token.
/// </summary>
/// <value><c>true</c> if the credentials are a bearer token; otherwise, <c>false</c>.</value>
public bool IsToken
{
get
{
return this.TokenCredential != null;
}
}

Expand Down Expand Up @@ -194,6 +212,15 @@ public StorageCredentials(string sasToken)
this.UpdateQueryBuilder();
}

/// <summary>
/// Initializes a new instance of the <see cref="StorageCredentials"/> class with the specified bearer token.
/// </summary>
/// <param name="tokenCredential">The authentication token.</param>
public StorageCredentials(TokenCredential tokenCredential)
{
this.TokenCredential = tokenCredential;
}

/// <summary>
/// Updates the key value for the credentials.
/// </summary>
Expand Down Expand Up @@ -331,6 +358,11 @@ private static string GetBase64EncodedKey(StorageAccountKey accountKey)
return (accountKey.KeyValue == null) ? null : Convert.ToBase64String(accountKey.KeyValue);
}

private static string GetTokenValue(TokenCredential tokenCredential)
{
return tokenCredential == null ? null : tokenCredential.Token;
}

internal string ToString(bool exportSecrets)
{
if (this.IsSharedKey)
Expand Down Expand Up @@ -371,7 +403,8 @@ public bool Equals(StorageCredentials other)
return string.Equals(this.SASToken, other.SASToken) &&
string.Equals(this.AccountName, other.AccountName) &&
string.Equals(thisAccountKey.KeyName, otherAccountKey.KeyName) &&
string.Equals(GetBase64EncodedKey(thisAccountKey), GetBase64EncodedKey(otherAccountKey));
string.Equals(GetBase64EncodedKey(thisAccountKey), GetBase64EncodedKey(otherAccountKey)) &&
string.Equals(GetTokenValue(this.TokenCredential), GetTokenValue(other.TokenCredential));
}
}

Expand Down
Loading

0 comments on commit a9841c9

Please sign in to comment.