1

I'm using Sitecore 9.1 and following Sitecore's guide in implementing Federated Authentication.

I am implementing Sitecore.Owin.Authentication.Pipelines.IdentityProviders.IdentityProvidersProcessor, that in Sitecore 9.1 has a constructor with the following signature:

protected IdentityProvidersProcessor(FederatedAuthenticationConfiguration federatedAuthenticationConfiguration, ICookieManager cookieManager, BaseSettings settings);

That in my implementation I'm leaving 'as is':

public MyOwnProcessor(
FederatedAuthenticationConfiguration federatedAuthenticationConfiguration,
Microsoft.Owin.Infrastructure.ICookieManager cookieManager,
Sitecore.Abstractions.BaseSettings settings) : 
base(federatedAuthenticationConfiguration, cookieManager, settings) {

}

And yet, I'm still getting the error

Could not create instance of type: MyProject.MyOwnProcessor. No matching constructor was found.

EDIT

Adding the entire code of my class:

namespace MyNamespace {
    public class MyOwnProcessor : IdentityProvidersProcessor {
        public MyOwnProcessor(FederatedAuthenticationConfiguration federatedAuthenticationConfiguration, Microsoft.Owin.Infrastructure.ICookieManager cookieManager, Sitecore.Abstractions.BaseSettings settings) : base(federatedAuthenticationConfiguration, cookieManager, settings) {

        }

        protected override string IdentityProviderName => "Okta";

        protected override void ProcessCore(IdentityProvidersArgs args) {
            // Currently does nothing, implementation pending
            string test = "test";
        }
    }
}

QUESTION

What could I be doing wrong? Do I need to provide some of these parameters in web.config perhaps?

2
  • Have to ask the obvious, but does MyOwnProcessor inherit IdentityProvidersProcessor?
    – Mark Cassidy
    Commented Jul 3, 2019 at 8:05
  • Yes it does indeed. Commented Jul 3, 2019 at 9:16

2 Answers 2

2

I think the code looking to instantiate your processor, is asking for the parameter-less constructor. Since you've not specified much around instantiation, this more or less has to be the case.

1) You're not following the cited Sitecore Guide which states:

To create a new processor:

Inherit the Sitecore.Owin.Authentication.Pipelines.IdentityProviders.IdentityProvidersProcessor class.

Override the IdentityProviderName property with the name you specified for the identityProvider in the configuration.

Override the ProcessCore method.

If this is followed to the letter, no constructor is to be defined.

2) If you look closer at the inherited class, all of the things you can inject via the constructor can also be populated on the class via properties. So in a property injection DI, the constructor becomes obsolete.

Remove your MyOwnProcessor constructor and I believe the problem will go away.

2
  • I did override IdentityProviderName and ProcessCore. The abstract class I'm inheriting from - Sitecore.Owin.Authentication.Pipelines.IdentityProviders.IdentityProvider - defines a constructor with the same signature of my own. Are you sure I can avoid implementing it? When I tried doing that, I get the standard CS7036 There is no argument given that corresponds to the required formal parameter... error. Commented Jul 3, 2019 at 9:26
  • I edited my question with the entire (WIP) code of my class. Commented Jul 3, 2019 at 9:26
1

It turns out, the class MyNamespace.MyOwnProcessor was referenced in another part of the config file - one where it didn't belong.

Lesson learned - check for all occurrences of your type when getting the "No matching constructor was found" error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.