Browse Source

Add IDS4 integration to the Web project.

pull/1148/head
Halil ibrahim Kalkan 7 years ago
parent
commit
77dec45e9c
  1. 5
      templates/mvc/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeeder.cs
  2. 10
      templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs
  3. 4
      templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/appsettings.json
  4. 4
      templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj
  5. 30
      templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
  6. 4
      templates/mvc/src/MyCompanyName.MyProjectName.Web/appsettings.json

5
templates/mvc/src/MyCompanyName.MyProjectName.IdentityServer/IdentityServerDataSeeder.cs → templates/mvc/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeeder.cs

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
@ -11,7 +10,7 @@ using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName.IdentityServer
{
public class IdentityServerDataSeeder : IDataSeedContributor, ITransientDependency
{
@ -99,6 +98,8 @@ namespace MyCompanyName.MyProjectName
"MyProjectName"
};
/* MyProjectName_Web client is only needed if you created tiered
* solution. Otherwise, delete this client. */
await CreateClientAsync(
"MyProjectName_Web",
commonScopes,

10
templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -29,6 +29,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.Web;
using Volo.Abp.TenantManagement.Web;
using Volo.Abp.Ui.Navigation.Urls;
using Volo.Abp.UI;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -67,6 +68,7 @@ namespace MyCompanyName.MyProjectName
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureUrls(configuration);
ConfigureAuthentication(context);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
@ -75,6 +77,14 @@ namespace MyCompanyName.MyProjectName
ConfigureMultiTenancy();
}
private void ConfigureUrls(IConfigurationRoot configuration)
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["AppSelfUrl"];
});
}
private void ConfigureMultiTenancy()
{
Configure<MultiTenancyOptions>(options => { options.IsEnabled = MultiTenancyConsts.IsMultiTenancyEnabled; });

4
templates/mvc/src/MyCompanyName.MyProjectName.Web.Host/appsettings.json

@ -1,10 +1,8 @@
{
"AppSelfUrl": "https://localhost:44314",
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44395/"
},
"AbpMvcClient": {
"BaseUrl": "https://localhost:44395/"
}
},
"Redis": {

4
templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj

@ -20,6 +20,7 @@
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
</ItemGroup>
<ItemGroup>
@ -28,8 +29,9 @@
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.JwtBearer\Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.Web\Volo.Abp.Identity.Web.csproj" />
<ProjectReference Include="..\..\..\..\modules\account\src\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj" />
<ProjectReference Include="..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.Web\Volo.Abp.TenantManagement.Web.csproj" />
<ProjectReference Include="..\..\..\..\modules\feature-management\src\Volo.Abp.FeatureManagement.Web\Volo.Abp.FeatureManagement.Web.csproj" />
</ItemGroup>

30
templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

@ -7,6 +7,7 @@ using MyCompanyName.MyProjectName.Localization.MyProjectName;
using MyCompanyName.MyProjectName.Menus;
using Swashbuckle.AspNetCore.Swagger;
using System.IO;
using Microsoft.Extensions.Configuration;
using MyCompanyName.MyProjectName.MultiTenancy;
using Volo.Abp;
using Volo.Abp.Account.Web;
@ -23,6 +24,7 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.Web;
using Volo.Abp.TenantManagement.Web;
using Volo.Abp.Ui.Navigation.Urls;
using Volo.Abp.UI;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
@ -35,7 +37,7 @@ namespace MyCompanyName.MyProjectName
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpIdentityWebModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpTenantManagementWebModule)
)]
@ -60,7 +62,9 @@ namespace MyCompanyName.MyProjectName
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices();
@ -69,6 +73,25 @@ namespace MyCompanyName.MyProjectName
ConfigureSwaggerServices(context.Services);
}
private void ConfigureUrls(IConfigurationRoot configuration)
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["AppSelfUrl"];
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfigurationRoot configuration)
{
context.Services.AddAuthentication()
.AddIdentityServerAuthentication(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = "MyProjectName";
});
}
private void ConfigureAutoMapper()
{
Configure<AbpAutoMapperOptions>(options =>
@ -164,12 +187,15 @@ namespace MyCompanyName.MyProjectName
app.UseVirtualFiles();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
if (MultiTenancyConsts.IsMultiTenancyEnabled)
{
app.UseMultiTenancy();
}
app.UseIdentityServer();
app.UseAbpRequestLocalization();
app.UseSwagger();

4
templates/mvc/src/MyCompanyName.MyProjectName.Web/appsettings.json

@ -1,5 +1,9 @@
{
"AppSelfUrl": "https://localhost:44361",
"ConnectionStrings": {
"Default": "Server=localhost;Database=MyProjectName;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"AuthServer": {
"Authority": "https://localhost:44361"
}
}
Loading…
Cancel
Save