From 05a65506a6dcc5e2793a0ba9e29e01adad6758d3 Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 27 Jan 2021 11:08:31 -0800 Subject: [PATCH 1/3] Extending TokenRequestContext to accept additional Claims --- eng/ApiListing.exclude-attributes.txt | 2 ++ .../Azure.Core/src/TokenRequestContext.cs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/eng/ApiListing.exclude-attributes.txt b/eng/ApiListing.exclude-attributes.txt index 78b9bdf9bcb51..cd890199bf466 100644 --- a/eng/ApiListing.exclude-attributes.txt +++ b/eng/ApiListing.exclude-attributes.txt @@ -1,3 +1,5 @@ T:System.Runtime.CompilerServices.AsyncIteratorStateMachineAttribute T:System.Runtime.CompilerServices.AsyncStateMachineAttribute T:System.Runtime.CompilerServices.CompilerGeneratedAttribute +T:System.Runtime.CompilerServices.NullableContextAttribute +T:System.Runtime.CompilerServices.NullableAttribute \ No newline at end of file diff --git a/sdk/core/Azure.Core/src/TokenRequestContext.cs b/sdk/core/Azure.Core/src/TokenRequestContext.cs index 5ce510582c10f..542fd828ebf5f 100644 --- a/sdk/core/Azure.Core/src/TokenRequestContext.cs +++ b/sdk/core/Azure.Core/src/TokenRequestContext.cs @@ -17,6 +17,20 @@ public TokenRequestContext(string[] scopes, string? parentRequestId = default) { Scopes = scopes; ParentRequestId = parentRequestId; + Claims = default; + } + + /// + /// Creates a new TokenRequest with the specified scopes. + /// + /// The scopes required for the token. + /// The of the request requiring a token for authentication, if applicable. + /// Additional claims to be included in the token. + public TokenRequestContext(string[] scopes, string? parentRequestId = default, string? claims = default) + { + Scopes = scopes; + ParentRequestId = parentRequestId; + Claims = claims; } /// @@ -28,5 +42,10 @@ public TokenRequestContext(string[] scopes, string? parentRequestId = default) /// The of the request requiring a token for authentication, if applicable. /// public string? ParentRequestId { get; } + + /// + /// Additional claims to be included in the token. + /// + public string? Claims { get; } } } From 041df75e7c825a0a5d3a012f08faa80093caa26a Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 27 Jan 2021 11:13:48 -0800 Subject: [PATCH 2/3] updating api definitions --- sdk/core/Azure.Core/api/Azure.Core.net461.cs | 2 ++ sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 2 ++ sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sdk/core/Azure.Core/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs index 5690e26096ccb..884e78e037d9e 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs @@ -417,6 +417,8 @@ public readonly partial struct TokenRequestContext private readonly object _dummy; private readonly int _dummyPrimitive; public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } + public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } public string[] Scopes { get { throw null; } } } diff --git a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs index e7a6b0df30ff0..a703beba572e4 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs @@ -417,6 +417,8 @@ public readonly partial struct TokenRequestContext private readonly object _dummy; private readonly int _dummyPrimitive; public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } + public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } public string[] Scopes { get { throw null; } } } diff --git a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs index 5690e26096ccb..884e78e037d9e 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs @@ -417,6 +417,8 @@ public readonly partial struct TokenRequestContext private readonly object _dummy; private readonly int _dummyPrimitive; public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } + public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } public string[] Scopes { get { throw null; } } } From 91164133e6fa6624fe731899d2cf04bfc870e11f Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Wed, 27 Jan 2021 12:10:35 -0800 Subject: [PATCH 3/3] fix ctor ambiguity --- sdk/core/Azure.Core/api/Azure.Core.net461.cs | 2 +- sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 2 +- sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs | 2 +- sdk/core/Azure.Core/src/TokenRequestContext.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/core/Azure.Core/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs index 884e78e037d9e..8c9615fd5d352 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs @@ -416,7 +416,7 @@ public readonly partial struct TokenRequestContext { private readonly object _dummy; private readonly int _dummyPrimitive; - public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId) { throw null; } public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } diff --git a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs index a703beba572e4..a9855e2e08fa8 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs @@ -416,7 +416,7 @@ public readonly partial struct TokenRequestContext { private readonly object _dummy; private readonly int _dummyPrimitive; - public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId) { throw null; } public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } diff --git a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs index 884e78e037d9e..8c9615fd5d352 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs @@ -416,7 +416,7 @@ public readonly partial struct TokenRequestContext { private readonly object _dummy; private readonly int _dummyPrimitive; - public TokenRequestContext(string[] scopes, string? parentRequestId = null) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId) { throw null; } public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null) { throw null; } public string? Claims { get { throw null; } } public string? ParentRequestId { get { throw null; } } diff --git a/sdk/core/Azure.Core/src/TokenRequestContext.cs b/sdk/core/Azure.Core/src/TokenRequestContext.cs index 542fd828ebf5f..fe4237f61b34d 100644 --- a/sdk/core/Azure.Core/src/TokenRequestContext.cs +++ b/sdk/core/Azure.Core/src/TokenRequestContext.cs @@ -13,7 +13,7 @@ public readonly struct TokenRequestContext /// /// The scopes required for the token. /// The of the request requiring a token for authentication, if applicable. - public TokenRequestContext(string[] scopes, string? parentRequestId = default) + public TokenRequestContext(string[] scopes, string? parentRequestId) { Scopes = scopes; ParentRequestId = parentRequestId;