JWT authentication issue with web api plugin in nopCommerce 4.30

空扰寡人 提交于 2021-01-24 15:52:14

问题


I implement JWT authentication for authorization using access token or bearer token in web api plugin with nopCommerce version 4.30. It is working fine with default source of nopCommerce 4.30. But when i used my API plugin with any Seven spikes plugins (SevenSpikes.Nop.Plugins.AjaxCart, SevenSpikes.Nop.Plugins.QuickView, etc), its not working and threw exception like "System.ArgumentException: 'Duplicate Controller with DuplicateControllerName:NopAjaxCartShoppingCart is already added'".

Here/below is my Code for configure method in startup file:

public void Configure(IApplicationBuilder app) { var dataSettings = DataSettingsManager.LoadSettings(); if (!dataSettings?.IsValid ?? true) return;

        var rewriteOptions = new RewriteOptions()
            .AddRewrite("oauth/(.*)", "connect/$1", true)
            .AddRewrite("api/token", "connect/token", true);

        app.UseRewriter(rewriteOptions);

        app.UseRouting();

        app.UseCors(x => x
            .AllowAnyOrigin()
            .AllowAnyMethod()
            .AllowAnyHeader());
        
        app.UseAuthorization();
        app.UseEndpoints(endpoints =>
        {
            //register all routes
            EngineContext.Current.Resolve<IRoutePublisher>().RegisterRoutes(endpoints);
        });
    }

来源:https://stackoverflow.com/questions/65772315/jwt-authentication-issue-with-web-api-plugin-in-nopcommerce-4-30

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!