问题
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