Skip to content

Conversation

@cpp11nullptr
Copy link

No description provided.


namespace Microsoft.Identity.Web
{
internal sealed class MsalMtlsHttpClientFactory : IMsalMtlsHttpClientFactory
Copy link
Member

@bgavrilMS bgavrilMS Oct 16, 2025

Choose a reason for hiding this comment

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

I don't understand the purpose of this class. It derives from IMsalMtlsHttpClientFactory and encapsulates an IMsalMtlsHttpClientFactory .

I think what you mean is for a class that dervices from IMsalMtlsHttpClientFactory but it should encapsulate System.Net.HttpIHttpClientFactory

Copy link
Author

Choose a reason for hiding this comment

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

I consider it more like an adaptor because IMsalMtlsHttpClientFactory doesn't derive from IHttpClientFactory, which means that it this class needed need to implement what SecureHttpClientFactory does but we'd have a code duplication between MSAL.NET and Identity.Web in this case. I don't have strong opinion there though, so it's better to have encapsulated IHttpClientFactory rather than IMsalMtlsHttpClientFactory, is it correct?

Copy link
Member

@bgavrilMS bgavrilMS Oct 16, 2025

Choose a reason for hiding this comment

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

I think the simplest for now is to intervene here:

- if mtls POP is used, don't add WithHttpClientFactory.

If you do want to inject HTTP transport, then you must provide an adapter between IHttpClientFactory and IMsalMtlsHttpClientFactory i.e.

public class Impl : IMsalMtlsHttpClientFactory 
{
  Impl(IHttpClientFactory aspFactory) { }
}

However, I am not sure how / if this ^^ adapter can be implemnted.

Copy link
Author

Choose a reason for hiding this comment

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

I changed it to use IHttpClientFactory for non-mTLS HTTP clients with managing a pool of mTLS clients, which are created in place (due to a fact that its handler needs to be configured before an actual instance is created).

// regardless of credential type being set, bound token requires a certificate
if (isTokenBinding)
{
if (credential.Certificate == null)
Copy link
Member

Choose a reason for hiding this comment

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

I think this works for a POC, but we probably need more abstraction here. Each credential may, or may not, be compatible with mTLS POP. In particular, I am thinking of the 2 FIC credentials.

CC @jmprieur @MZOLN

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.

2 participants