Skip to content

Commit

Permalink
Extending TokenRequestContext to accept additional Claims (#18236)
Browse files Browse the repository at this point in the history
* Extending TokenRequestContext to accept additional Claims

* updating api definitions

* fix ctor ambiguity
  • Loading branch information
schaabs authored Feb 2, 2021
1 parent 6ae4811 commit 061c377
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions eng/ApiListing.exclude-attributes.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net461.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
}
Expand Down
4 changes: 3 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
}
Expand Down
4 changes: 3 additions & 1 deletion sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
}
Expand Down
21 changes: 20 additions & 1 deletion sdk/core/Azure.Core/src/TokenRequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@ public readonly struct TokenRequestContext
/// </summary>
/// <param name="scopes">The scopes required for the token.</param>
/// <param name="parentRequestId">The <see cref="Request.ClientRequestId"/> of the request requiring a token for authentication, if applicable.</param>
public TokenRequestContext(string[] scopes, string? parentRequestId = default)
public TokenRequestContext(string[] scopes, string? parentRequestId)
{
Scopes = scopes;
ParentRequestId = parentRequestId;
Claims = default;
}

/// <summary>
/// Creates a new TokenRequest with the specified scopes.
/// </summary>
/// <param name="scopes">The scopes required for the token.</param>
/// <param name="parentRequestId">The <see cref="Request.ClientRequestId"/> of the request requiring a token for authentication, if applicable.</param>
/// <param name="claims">Additional claims to be included in the token.</param>
public TokenRequestContext(string[] scopes, string? parentRequestId = default, string? claims = default)
{
Scopes = scopes;
ParentRequestId = parentRequestId;
Claims = claims;
}

/// <summary>
Expand All @@ -28,5 +42,10 @@ public TokenRequestContext(string[] scopes, string? parentRequestId = default)
/// The <see cref="Request.ClientRequestId"/> of the request requiring a token for authentication, if applicable.
/// </summary>
public string? ParentRequestId { get; }

/// <summary>
/// Additional claims to be included in the token.
/// </summary>
public string? Claims { get; }
}
}

0 comments on commit 061c377

Please sign in to comment.