Can I register a SamlClaimFactory with DI?

I noticed that in order to register my own implementation of IClaimFactory I have to do this: options.ClaimFactory = new MyClaimFactory…

This is not ideal because if my ClaimFactory takes dependencies like ILogger then I end up having to do this:
// Add SAML authentication services.
.AddSaml(options =>
// Loads the types in for the SamlClaimFactory singleton below
var samlClaimFactoryConfiguration = services.BuildServiceProvider().GetService<IOptionsSnapshot>();
var claimFactoryLogger = services.BuildServiceProvider().GetService<ILogger<Services.SamlClaimFactory>>(); // <------------------------------ not good

options.ClaimFactory = new Services.SamlClaimFactory(samlClaimFactoryConfiguration, claimFactoryLogger);
options.PartnerName = Configuration[“PartnerName”];
options.SignInScheme = IdentityServer4.IdentityServerConstants.ExternalCookieAuthenticationScheme;

So my question is why do you guys just not add a default claim factory as a singleton when AddSaml is called? A perfect way to implement this would be like IdentityServer does it here and here is the code where they let you add your own and here is where they try and add the default impl.

Here is a sample of what your code would look like:


That’s a good point.
Look for an update in the forthcoming release.
If you’d like to beta test, please contact us at mentioning this topic.