Skip to content

Conversation

@MZOLN
Copy link

@MZOLN MZOLN commented Nov 24, 2025

Add support for calling WithClientClaims flow for token acquisition

Enabling MSAL's WithClientClaims flavor of client assertions call and exposing it through IdWeb.

private static IDictionary<string, string>? GetClientClaimsIfExist(TokenAcquisitionOptions? tokenAcquisitionOptions)
{
IDictionary<string, string>? clientClaims = null;
if (tokenAcquisitionOptions is not null && tokenAcquisitionOptions.ExtraParameters is not null &&
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, im not sure it is best to use client claims with the ExtraParameters collection. This collection is meant for very generic parameters that we dont know all the details of. For example, the attribute feature was not meant to be exposed in MSAL/IdWeb so this generic collection was used. I think in this case, we should expose the client claims in the abstractions because it is a known value for MSAL. CC @bgavrilMS

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 to what Travis is saying. If developers need to know about it it should be in Abstractions. If we don't want people to mess around with it it should be in ExtraParameters.

Aside:

  1. is it a per request or per app parameter. If it's considered at CCA building time as it seems to be, shouldn't it be in MicrosoftIdentityApplicationOptions ?

Copy link
Member

@bgavrilMS bgavrilMS Dec 5, 2025

Choose a reason for hiding this comment

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

  1. I think it is a fairly obscure scenario , I am not aware of any 3p needing this. I'm fine either way, with a slight inclination towards keeping it in ExtraParameters
  2. yeah in MSAL it is on a "per app" basis. I believe the CX needs it on a per app basis as well - @trwalke pls confirm.

Copy link
Member

Choose a reason for hiding this comment

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

@jmprieur Yeah, I added to the application options

Copy link
Collaborator

Choose a reason for hiding this comment

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

@bgavrilMS @trwalke please ping me offline with the customer scenario.
This PR, @trwalke, is not compatible with AzureAD/microsoft-identity-abstractions-for-dotnet#230

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I agree with that comment. This was a PoC. The whole point was to make it work quickly with avoiding having to update abstractions, but then we agreed that it could stay that way (?)

Copy link
Author

@MZOLN MZOLN Dec 9, 2025

Choose a reason for hiding this comment

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

Currently customers were passing it per request with Adal... but Im not sure it would be changing that often. There would probably be a grouping per application.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It could. I just don't understand if it's on the request or the app. I see both in different places in these 2 prs

public HttpClient GetHttpClient() => _httpClient;
}

private class CapturingHandler : HttpMessageHandler
Copy link
Member

Choose a reason for hiding this comment

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

we already have a mocking framework to capture MSAL traffic and reply with test responses. i can update the tests to use them
see: https://github.com/AzureAD/microsoft-identity-web/blob/master/tests/Microsoft.Identity.Web.Test.Common/Mocks/MockHttpClientFactory.cs

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good to me.

private static IDictionary<string, string>? GetClientClaimsIfExist(TokenAcquisitionOptions? tokenAcquisitionOptions)
{
IDictionary<string, string>? clientClaims = null;
if (tokenAcquisitionOptions is not null && tokenAcquisitionOptions.ExtraParameters is not null &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 to what Travis is saying. If developers need to know about it it should be in Abstractions. If we don't want people to mess around with it it should be in ExtraParameters.

Aside:

  1. is it a per request or per app parameter. If it's considered at CCA building time as it seems to be, shouldn't it be in MicrosoftIdentityApplicationOptions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants