From ab954afa7f623e03789797d3a12ae422147f91ae Mon Sep 17 00:00:00 2001 From: Scott Schaab Date: Tue, 2 Feb 2021 11:45:49 -0800 Subject: [PATCH] Extending TokenRequestContext to accept additional Claims (#18236) * Extending TokenRequestContext to accept additional Claims * updating api definitions * fix ctor ambiguity --- eng/ApiListing.exclude-attributes.txt | 2 ++ sdk/core/Azure.Core/api/Azure.Core.net461.cs | 4 +++- sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 4 +++- .../api/Azure.Core.netstandard2.0.cs | 4 +++- .../Azure.Core/src/TokenRequestContext.cs | 21 ++++++++++++++++++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/eng/ApiListing.exclude-attributes.txt b/eng/ApiListing.exclude-attributes.txt index 78b9bdf9bcb5..cd890199bf46 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/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs index 08ee25bd1f0d..053e05af4245 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs @@ -428,7 +428,9 @@ 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; } } 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 76cca4e18084..d12ef3a649da 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs @@ -428,7 +428,9 @@ 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; } } 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 08ee25bd1f0d..053e05af4245 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs @@ -428,7 +428,9 @@ 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; } } public string[] Scopes { get { throw null; } } } diff --git a/sdk/core/Azure.Core/src/TokenRequestContext.cs b/sdk/core/Azure.Core/src/TokenRequestContext.cs index 5ce510582c10..fe4237f61b34 100644 --- a/sdk/core/Azure.Core/src/TokenRequestContext.cs +++ b/sdk/core/Azure.Core/src/TokenRequestContext.cs @@ -13,10 +13,24 @@ 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; + 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; } } }