Skip to content

Commit

Permalink
Mixed Reality Authentication: Updated the MR STS spec file (Azure#18341)
Browse files Browse the repository at this point in the history
This change updated the library to consume the latest version of spec file, which changes the account identifier to be a `Guid` rather than a `string`. The service expects a `Guid` or `UUID`, so it makes sense to be specific.
  • Loading branch information
craigktreasure authored and jongio committed Feb 9, 2021
1 parent 2d0be7b commit 7461ec2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 1.0.0-preview.3 (2021-01-15)

- Updated to latest version of spec file which changes the account identifier to be a `Guid` rather than a `string`.

## 1.0.0-preview.2 (2021-01-12)

- Configured with shared source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ namespace Azure.MixedReality.Authentication
public partial class MixedRealityStsClient
{
protected MixedRealityStsClient() { }
public MixedRealityStsClient(string accountId, string accountDomain, Azure.AzureKeyCredential keyCredential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(string accountId, string accountDomain, Azure.Core.TokenCredential credential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(string accountId, System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(string accountId, System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public string AccountId { get { throw null; } }
public MixedRealityStsClient(System.Guid accountId, string accountDomain, Azure.AzureKeyCredential keyCredential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(System.Guid accountId, string accountDomain, Azure.Core.TokenCredential credential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(System.Guid accountId, System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public MixedRealityStsClient(System.Guid accountId, System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.MixedReality.Authentication.MixedRealityStsClientOptions? options = null) { }
public System.Guid AccountId { get { throw null; } }
public System.Uri Endpoint { get { throw null; } }
public virtual Azure.Response<Azure.Core.AccessToken> GetToken(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> GetTokenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.MixedReality.Authentication
/// <seealso cref="TokenCredential" />
internal class MixedRealityAccountKeyCredential : TokenCredential
{
private readonly string _accountId;
private readonly Guid _accountId;

private readonly AzureKeyCredential _accountKey;

Expand All @@ -23,7 +23,7 @@ internal class MixedRealityAccountKeyCredential : TokenCredential
/// </summary>
/// <param name="accountId">The Mixed Reality service account identifier.</param>
/// <param name="accountKey">The Mixed Reality service account primary or secondary key.</param>
public MixedRealityAccountKeyCredential(string accountId, string accountKey)
public MixedRealityAccountKeyCredential(Guid accountId, string accountKey)
: this(accountId, new AzureKeyCredential(accountKey))
{
}
Expand All @@ -33,9 +33,9 @@ public MixedRealityAccountKeyCredential(string accountId, string accountKey)
/// </summary>
/// <param name="accountId">The Mixed Reality service account identifier.</param>
/// <param name="keyCredential">The Mixed Reality service account primary or secondary key credential.</param>
public MixedRealityAccountKeyCredential(string accountId, AzureKeyCredential keyCredential)
public MixedRealityAccountKeyCredential(Guid accountId, AzureKeyCredential keyCredential)
{
Argument.AssertNotNullOrWhiteSpace(accountId, nameof(accountId));
Argument.AssertNotDefault(ref accountId, nameof(accountId));
Argument.AssertNotNull(keyCredential, nameof(keyCredential));

_accountId = accountId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class MixedRealityTokenCredential : TokenCredential
/// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
/// <param name="credential">The credential used to access the Mixed Reality service.</param>
/// <param name="options">The options.</param>
private MixedRealityTokenCredential(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
private MixedRealityTokenCredential(Guid accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
{
_stsClient = new MixedRealityStsClient(accountId, endpoint, credential, options);
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext r
/// <param name="credential">The credential used to access the Mixed Reality service.</param>
/// <param name="options">The options.</param>
/// <returns><see cref="TokenCredential"/>.</returns>
public static TokenCredential GetMixedRealityCredential(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
public static TokenCredential GetMixedRealityCredential(Guid accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
{
if (credential is StaticAccessTokenCredential)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MixedRealityStsClient
/// <summary>
/// Gets the Mixed Reality service account identifier.
/// </summary>
public string AccountId { get; }
public Guid AccountId { get; }

/// <summary>
/// The Mixed Reality STS service endpoint.
Expand All @@ -37,7 +37,7 @@ public class MixedRealityStsClient
/// <param name="accountDomain">The Mixed Reality service account domain.</param>
/// <param name="keyCredential">The Mixed Reality service account primary or secondary key credential.</param>
/// <param name="options">The options.</param>
public MixedRealityStsClient(string accountId, string accountDomain, AzureKeyCredential keyCredential, MixedRealityStsClientOptions? options = null)
public MixedRealityStsClient(Guid accountId, string accountDomain, AzureKeyCredential keyCredential, MixedRealityStsClientOptions? options = null)
: this(accountId, AuthenticationEndpoint.ConstructFromDomain(accountDomain), new MixedRealityAccountKeyCredential(accountId, keyCredential), options) { }

/// <summary>
Expand All @@ -47,7 +47,7 @@ public MixedRealityStsClient(string accountId, string accountDomain, AzureKeyCre
/// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
/// <param name="keyCredential">The Mixed Reality service account primary or secondary key credential.</param>
/// <param name="options">The options.</param>
public MixedRealityStsClient(string accountId, Uri endpoint, AzureKeyCredential keyCredential, MixedRealityStsClientOptions? options = null)
public MixedRealityStsClient(Guid accountId, Uri endpoint, AzureKeyCredential keyCredential, MixedRealityStsClientOptions? options = null)
: this(accountId, endpoint, new MixedRealityAccountKeyCredential(accountId, keyCredential), options) { }

/// <summary>
Expand All @@ -57,7 +57,7 @@ public MixedRealityStsClient(string accountId, Uri endpoint, AzureKeyCredential
/// <param name="accountDomain">The Mixed Reality service account domain.</param>
/// <param name="credential">The credential used to access the Mixed Reality service.</param>
/// <param name="options">The options.</param>
public MixedRealityStsClient(string accountId, string accountDomain, TokenCredential credential, MixedRealityStsClientOptions? options = null)
public MixedRealityStsClient(Guid accountId, string accountDomain, TokenCredential credential, MixedRealityStsClientOptions? options = null)
: this(accountId, AuthenticationEndpoint.ConstructFromDomain(accountDomain), credential, options) { }

/// <summary>
Expand All @@ -67,9 +67,9 @@ public MixedRealityStsClient(string accountId, string accountDomain, TokenCreden
/// <param name="endpoint">The Mixed Reality STS service endpoint.</param>
/// <param name="credential">The credential used to access the Mixed Reality service.</param>
/// <param name="options">The options.</param>
public MixedRealityStsClient(string accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
public MixedRealityStsClient(Guid accountId, Uri endpoint, TokenCredential credential, MixedRealityStsClientOptions? options = null)
{
Argument.AssertNotNull(accountId, nameof(accountId));
Argument.AssertNotDefault(ref accountId, nameof(accountId));
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Run `dotnet build /t:GenerateCode` to generate code.

``` yaml
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/e0b78897850ccbb648b3efe286b78e78c5cd8bcf/specification/mixedreality/data-plane/Microsoft.MixedReality/preview/2019-02-28-preview/mr-sts.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/aa19725fe79aea2a9dc580f3c66f77f89cc34563/specification/mixedreality/data-plane/Microsoft.MixedReality/preview/2019-02-28-preview/mr-sts.json
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Core.TestFramework;
Expand All @@ -22,7 +23,7 @@ public MixedRealityStsClientLiveTests(bool isAsync)
private MixedRealityStsClient CreateClient()
{
string mixedRealityAccountDomain = TestEnvironment.AccountDomain;
string mixedRealityAccountId = TestEnvironment.AccountId;
Guid mixedRealityAccountId = Guid.Parse(TestEnvironment.AccountId);
string mixedRealityAccountKey = TestEnvironment.AccountKey;

return InstrumentClient(new MixedRealityStsClient(
Expand Down

0 comments on commit 7461ec2

Please sign in to comment.