Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending TokenRequestContext to accept additional Claims #18236

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -416,7 +416,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; } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Claims" is plural but not a collection while Scopes is. Why?

Copy link
Member Author

@schaabs schaabs Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of this property actually corresponds to the claims parameter in OpenID, a complex json object containing a collection of claims which need to be included in the issued token (I will add more detail on this to the xml comments). Given that do you still have an issue with the property name being plural?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, does it follow some spec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://openid.net/specs/openid-connect-core-1_0-final.html#ClaimsParameter, I can link to this directly in the doc comments.

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 @@ -416,7 +416,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 @@ -416,7 +416,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; }
}
}