Browse Source

Authorize clients for tenant management service, configure gateways and make the console client demo working.

pull/3032/head
Halil İbrahim Kalkan 6 years ago
parent
commit
ca246162ef
  1. 1
      samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj
  2. 7
      samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerDataSeeder.cs
  3. 6
      samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs
  4. 36
      samples/MicroserviceDemo/applications/ConsoleClientDemo/ClientDemoService.cs
  5. 1
      samples/MicroserviceDemo/applications/ConsoleClientDemo/ConsoleClientDemo.csproj
  6. 4
      samples/MicroserviceDemo/applications/ConsoleClientDemo/ConsoleClientDemoModule.cs
  7. 2
      samples/MicroserviceDemo/applications/ConsoleClientDemo/appsettings.json
  8. 12
      samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json
  9. 1
      samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj
  10. 4
      samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs
  11. 12
      samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json
  12. 2
      samples/MicroserviceDemo/microservices/TenantManagementService.Host/Properties/launchSettings.json

1
samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj

@ -33,6 +33,7 @@
<ProjectReference Include="..\..\..\..\modules\audit-logging\src\Volo.Abp.AuditLogging.EntityFrameworkCore\Volo.Abp.AuditLogging.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.EntityFrameworkCore\Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.Application.Contracts\Volo.Abp.TenantManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.EntityFrameworkCore\Volo.Abp.TenantManagement.EntityFrameworkCore.csproj" />
</ItemGroup>

7
samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerDataSeeder.cs

@ -10,6 +10,7 @@ using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.PermissionManagement;
using Volo.Abp.TenantManagement;
using Volo.Abp.Uow;
namespace AuthServer.Host
@ -107,15 +108,15 @@ namespace AuthServer.Host
await CreateClientAsync(
"console-client-demo",
new[] { "BloggingService", "IdentityService", "InternalGateway", "ProductService" },
new[] { "BloggingService", "IdentityService", "InternalGateway", "ProductService", "TenantManagementService" },
new[] { "client_credentials", "password" },
commonSecret,
permissions: new[] { IdentityPermissions.Users.Default, "ProductManagement.Product" }
permissions: new[] { IdentityPermissions.Users.Default, TenantManagementPermissions.Tenants.Default, "ProductManagement.Product" }
);
await CreateClientAsync(
"backend-admin-app-client",
commonScopes.Union(new[] { "BackendAdminAppGateway", "IdentityService", "ProductService" }),
commonScopes.Union(new[] { "BackendAdminAppGateway", "IdentityService", "ProductService", "TenantManagementService" }),
new[] { "hybrid" },
commonSecret,
permissions: new[] { IdentityPermissions.Users.Default, "ProductManagement.Product" },

6
samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs

@ -22,6 +22,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
@ -40,8 +41,9 @@ namespace AuthServer.Host
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule)
)]
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementApplicationContractsModule)
)]
public class AuthServerHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)

36
samples/MicroserviceDemo/applications/ConsoleClientDemo/ClientDemoService.cs

@ -7,12 +7,14 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Identity;
using Volo.Abp.IdentityModel;
using Volo.Abp.TenantManagement;
namespace ConsoleClientDemo
{
public class ClientDemoService : ITransientDependency
{
private readonly IIdentityUserAppService _userAppService;
private readonly ITenantAppService _tenantAppService;
private readonly IProductAppService _productAppService;
private readonly IIdentityModelAuthenticationService _authenticator;
private readonly AbpRemoteServiceOptions _remoteServiceOptions;
@ -21,10 +23,12 @@ namespace ConsoleClientDemo
IIdentityUserAppService userAppService,
IProductAppService productAppService,
IIdentityModelAuthenticationService authenticator,
IOptions<AbpRemoteServiceOptions> remoteServiceOptions)
IOptions<AbpRemoteServiceOptions> remoteServiceOptions,
ITenantAppService tenantAppService)
{
_userAppService = userAppService;
_authenticator = authenticator;
_tenantAppService = tenantAppService;
_remoteServiceOptions = remoteServiceOptions.Value;
_productAppService = productAppService;
}
@ -33,6 +37,7 @@ namespace ConsoleClientDemo
{
await TestWithHttpClient();
await TestIdentityService();
await TestTenantManagementService();
await TestProductService();
}
@ -101,6 +106,35 @@ namespace ConsoleClientDemo
}
}
/// <summary>
/// Shows how to use application service interfaces (ITenantAppService in this sample)
/// to call a remote service which is possible by the dynamic http client proxy system.
/// No need to use IIdentityModelAuthenticationService since the dynamic http client proxy
/// system internally uses it. You just inject a service (ITenantAppService)
/// and call a method (GetListAsync) like a local method.
/// </summary>
private async Task TestTenantManagementService()
{
Console.WriteLine();
Console.WriteLine("*** TestTenantManagementService ************************************");
try
{
var output = await _tenantAppService.GetListAsync(new GetTenantsInput());
Console.WriteLine("Total tenant count: " + output.TotalCount);
foreach (var tenant in output.Items)
{
Console.WriteLine($"- Id={tenant.Id}, Name={tenant.Name}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
/// <summary>
/// Shows how to use application service interfaces (IProductAppService in this sample)
/// to call a remote service which is possible by the dynamic http client proxy system.

1
samples/MicroserviceDemo/applications/ConsoleClientDemo/ConsoleClientDemo.csproj

@ -14,6 +14,7 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel\Volo.Abp.Http.Client.IdentityModel.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi.Client\Volo.Abp.Identity.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.HttpApi.Client\Volo.Abp.TenantManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\modules\product\src\ProductManagement.HttpApi.Client\ProductManagement.HttpApi.Client.csproj" />
</ItemGroup>

4
samples/MicroserviceDemo/applications/ConsoleClientDemo/ConsoleClientDemoModule.cs

@ -3,6 +3,7 @@ using Volo.Abp.Autofac;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.TenantManagement;
namespace ConsoleClientDemo
{
@ -10,7 +11,8 @@ namespace ConsoleClientDemo
typeof(AbpAutofacModule),
typeof(AbpHttpClientIdentityModelModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(ProductManagementHttpApiClientModule)
typeof(ProductManagementHttpApiClientModule),
typeof(AbpTenantManagementHttpApiClientModule)
)]
public class ConsoleClientDemoModule : AbpModule
{

2
samples/MicroserviceDemo/applications/ConsoleClientDemo/appsettings.json

@ -10,7 +10,7 @@
"ClientId": "console-client-demo",
"ClientSecret": "1q2w3e*",
"Authority": "http://localhost:64999",
"Scope": "InternalGateway IdentityService ProductService"
"Scope": "InternalGateway IdentityService ProductService TenantManagementService"
}
}
}

12
samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/appsettings.json

@ -30,6 +30,18 @@
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/multi-tenancy/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 59835
}
],
"UpstreamPathTemplate": "/api/multi-tenancy/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/productManagement/{everything}",
"DownstreamScheme": "http",

1
samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj

@ -26,6 +26,7 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.HttpApi\Volo.Abp.TenantManagement.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\modules\blogging\src\Volo.Blogging.HttpApi\Volo.Blogging.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.EntityFrameworkCore\Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />

4
samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs

@ -19,6 +19,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Blogging;
namespace InternalGateway.Host
@ -30,7 +31,8 @@ namespace InternalGateway.Host
typeof(ProductManagementHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule)
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementHttpApiModule)
)]
public class InternalGatewayHostModule : AbpModule
{

12
samples/MicroserviceDemo/gateways/InternalGateway.Host/appsettings.json

@ -25,6 +25,18 @@
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/multi-tenancy/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 59835
}
],
"UpstreamPathTemplate": "/api/multi-tenancy/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/productManagement/{everything}",
"DownstreamScheme": "http",

2
samples/MicroserviceDemo/microservices/TenantManagementService.Host/Properties/launchSettings.json

@ -18,7 +18,7 @@
"TenantManagementService.Host": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"applicationUrl": "http://localhost:59835",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

Loading…
Cancel
Save