OWIN Startup in Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 anni tempo fa
Does anyone know how to integrate an OWIN component as a plugin?

I am working on a project that uses Azure Active Directory authentication through OAuth/OpenID Connect for login. It would be pretty simple to just use the OpenID Connect OWIN components, but I can't figure how to register the OWIN components from within the plugin.

I'd prefer not to modify any of the nopCommerce source--can this be done through a plugin only?
8 anni tempo fa
Yes, this is possible in the new nopCommerce 3.7.

You need to do 2 things:

1. Have a Startup class in your plugin. Have a Configuration method that will be called by the Owin Host to allow you to add your Owin Middlewares.

2. Enable the OwinAutomaticAppStartup setting in the Web.config. The setting is already present in the Web.config and you just need to change its value from False to True.

This way you can register your Owin components in your plugin's StartUp class Configuration method.

You can read more here:
http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection

Hope this helps!
8 anni tempo fa
Thanks for that info--I was hoping it wouldn't be too difficult. I'm currently on 3.40, do you have any idea if it will work on that version?
8 anni tempo fa
dforst wrote:
Thanks for that info--I was hoping it wouldn't be too difficult. I'm currently on 3.40, do you have any idea if it will work on that version?


You update your version to nop 3.70.
8 anni tempo fa
dforst wrote:
Thanks for that info--I was hoping it wouldn't be too difficult. I'm currently on 3.40, do you have any idea if it will work on that version?


Hi dforst,

It won't work in 3.4 without modifications to Nop.Web project, which will defeat the purpose of having a Plugin.
8 anni tempo fa
Thanks everyone for your help so far. I upgraded to 3.70 and can confirm that the the OWIN startup is registered and run.

My problem though is it isn't triggering the external (Azure AD) login form. I have nop configured to not allow browsing without being logged-in, but I only get the standard nop login form, not the Azure AD form hosed by Microsoft.

I have a test application the runs the same code and I get the Azure AD form as expected. What do I need to do so nopCommerce will trigger the external login form?
8 anni tempo fa
I figured out my problem. I had to remove the forms authentication setting from the web.config and all works fine now. Thanks to everyone for your help.
6 anni tempo fa
i am trying same thing, i have another plugin also which has startup class, how on muliple plugins we can apply startup classes?
6 anni tempo fa
Can someone post an example of how I can get my plugin to run the following code?

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvcCore().AddProtobufFormatters();
            RuntimeTypeModel.Default.Add(typeof(DateTimeOffset),

I need it to add protobufformatters at startup some how but cannot figure out how to get Startup.cs to be recognised.
6 anni tempo fa
I found INopStartup which looks like it might be what I need, just can't find much information on how to use it.

edit: Yep implementing INopStartup was all that was required. Fantastic. It seems you guys really think of everything.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.