diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs
index 9a6e49e32a..57d4d22992 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs
@@ -196,7 +196,8 @@ public class MyProjectNameAuthServerModule : AbpModule
app.UseRouting();
app.UseCors();
app.UseAuthentication();
-
+ app.UseAbpOpenIddictValidation();
+
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj
index c456030c2a..1ca867ba78 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj
@@ -52,7 +52,7 @@
-
+
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
index fb5079b2e9..bc47df706c 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
@@ -11,6 +11,7 @@ using MyCompanyName.MyProjectName.Localization;
using MyCompanyName.MyProjectName.MultiTenancy;
using MyCompanyName.MyProjectName.Web.Menus;
using Microsoft.OpenApi.Models;
+using OpenIddict.Validation.AspNetCore;
using Volo.Abp;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc;
@@ -47,7 +48,7 @@ namespace MyCompanyName.MyProjectName.Web;
typeof(AbpAutofacModule),
typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule),
- typeof(AbpAccountWebModule),
+ typeof(AbpAccountWebOpenIddictModule),
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
@@ -68,6 +69,16 @@ public class MyProjectNameWebModule : AbpModule
typeof(MyProjectNameWebModule).Assembly
);
});
+
+ PreConfigure(builder =>
+ {
+ builder.AddValidation(options =>
+ {
+ options.AddAudiences("MyProjectName");
+ options.UseLocalServer();
+ options.UseAspNetCore();
+ });
+ });
}
public override void ConfigureServices(ServiceConfigurationContext context)
@@ -75,6 +86,7 @@ public class MyProjectNameWebModule : AbpModule
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
+ ConfigureAuthentication(context);
ConfigureUrls(configuration);
ConfigureBundles();
ConfigureAutoMapper();
@@ -84,6 +96,11 @@ public class MyProjectNameWebModule : AbpModule
ConfigureAutoApiControllers();
ConfigureSwaggerServices(context.Services);
}
+
+ private void ConfigureAuthentication(ServiceConfigurationContext context)
+ {
+ context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
+ }
private void ConfigureUrls(IConfiguration configuration)
{
@@ -106,7 +123,7 @@ public class MyProjectNameWebModule : AbpModule
);
});
}
-
+
private void ConfigureAutoMapper()
{
Configure(options =>
@@ -130,7 +147,7 @@ public class MyProjectNameWebModule : AbpModule
options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
- options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar)));
+ options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web.OpenIddict", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar)));
//
options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared"));
@@ -218,6 +235,7 @@ public class MyProjectNameWebModule : AbpModule
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
+ app.UseAbpOpenIddictValidation();
if (MultiTenancyConsts.IsEnabled)
{