-
Notifications
You must be signed in to change notification settings - Fork 241
[POC] Use secure HTTP client factory and force certificate credential for token binding #3559
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| namespace Microsoft.Identity.Web | ||
| { | ||
| internal sealed class MsalMtlsHttpClientFactory : IMsalMtlsHttpClientFactory |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
microsoft-identity-web/src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquisition.cs
Line 933 in a8b9273
| .WithHttpClientFactory(_httpClientFactory) |
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.