Browse Source

Merge branch 'master' of https://github.com/Nokecy/abp

pull/817/head
Nokecy 7 years ago
parent
commit
762c5bc79a
  1. 2
      common.props
  2. 96
      docs/en/AspNetCore/Dynamic-CSharp-API-Clients.md
  3. 16
      framework/Volo.Abp.sln
  4. 22
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj
  5. 26
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs
  6. 65
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/CachedApplicationConfigurationClient.cs
  7. 10
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs
  8. 32
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs
  9. 20
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj
  10. 13
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs
  11. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs
  12. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs
  13. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs
  14. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs
  15. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs
  16. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs
  17. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
  18. 15
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
  19. 40
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  20. 13
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs
  21. 8
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
  22. 1
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
  23. 4
      framework/src/Volo.Abp.Authorization/Microsoft/Extensions/DependencyInjection/AbpAuthorizationServiceCollectionExtensions.cs
  24. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs
  25. 6
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs
  26. 114
      framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs
  27. 12
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/HttpClientProxy.cs
  28. 7
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IHttpClientProxy.cs
  29. 2
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs
  30. 2
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs
  31. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
  32. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceDataSeeder.cs
  33. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestBaseModule.cs
  34. 20
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  35. 2
      modules/tenant-management/test/Volo.Abp.TenantManagement.Application.Tests/Volo/Abp/TenantManagement/AbpTenantManagementApplicationTestModule.cs
  36. 4
      nupkg/common.ps1
  37. 2
      samples/BookStore/src/Acme.BookStore.Application/Acme.BookStore.Application.csproj
  38. 2
      samples/BookStore/src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj
  39. 8
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj
  40. 460
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20190111135616_ABP_v0_11_Upgrade.Designer.cs
  41. 42
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20190111135616_ABP_v0_11_Upgrade.cs
  42. 44
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/BookStoreDbContextModelSnapshot.cs
  43. 8
      samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj
  44. 50
      samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs
  45. 4
      samples/BookStore/test/Acme.BookStore.Application.Tests/Acme.BookStore.Application.Tests.csproj
  46. 4
      samples/BookStore/test/Acme.BookStore.ConsoleApiClient/Acme.BookStore.ConsoleApiClient.csproj
  47. 11
      samples/BookStore/test/Acme.BookStore.ConsoleApiClient/ConsoleApiClientModule.cs
  48. 2
      samples/BookStore/test/Acme.BookStore.Web.Tests/Acme.BookStore.Web.Tests.csproj
  49. 2
      templates/module/test/MyCompanyName.MyProjectName.TestBase/MyCompanyName/MyProjectName/MyProjectNameTestBaseModule.cs
  50. 46
      templates/mvc/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
  51. 7
      templates/service/host/IdentityServerHost/IdentityServerDataSeeder.cs
  52. 2
      templates/service/test/MyCompanyName.MyProjectName.TestBase/MyCompanyName/MyProjectName/MyProjectNameTestBaseModule.cs

2
common.props

@ -1,7 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Version>0.11.0</Version> <Version>0.12.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageIconUrl>https://abp.io/assets/abp_nupkg.png</PackageIconUrl> <PackageIconUrl>https://abp.io/assets/abp_nupkg.png</PackageIconUrl>
<PackageProjectUrl>https://abp.io</PackageProjectUrl> <PackageProjectUrl>https://abp.io</PackageProjectUrl>

96
docs/en/AspNetCore/Dynamic-CSharp-API-Clients.md

@ -7,13 +7,13 @@ ABP can dynamically create C# API client proxies to call remote HTTP services (R
Your service/controller should implement an interface that is shared between the server and the client. So, first define a service interface in a shared library project. Example: Your service/controller should implement an interface that is shared between the server and the client. So, first define a service interface in a shared library project. Example:
````csharp ````csharp
public interface IBookService : IApplicationService public interface IBookAppService : IApplicationService
{ {
Task<List<BookDto>> GetListAsync(); Task<List<BookDto>> GetListAsync();
} }
```` ````
Your interface should implement the `IRemoteService` interface. Since the `IApplicationService` inherits the `IRemoteService` interface, the `IBookService` above satisfies this condition. Your interface should implement the `IRemoteService` interface to be automatically discovered. Since the `IApplicationService` inherits the `IRemoteService` interface, the `IBookAppService` above satisfies this condition.
Implement this class in your service application. You can use [auto API controller system](Auto-API-Controllers.md) to expose the service as a REST API endpoint. Implement this class in your service application. You can use [auto API controller system](Auto-API-Controllers.md) to expose the service as a REST API endpoint.
@ -45,13 +45,6 @@ public class MyClientAppModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
//Configure remote end point
context.Services.Configure<RemoteServiceOptions>(options =>
{
options.RemoteServices.Default =
new RemoteServiceConfiguration("http://localhost:53929/");
});
//Create dynamic client proxies //Create dynamic client proxies
context.Services.AddHttpClientProxies( context.Services.AddHttpClientProxies(
typeof(BookStoreApplicationModule).Assembly typeof(BookStoreApplicationModule).Assembly
@ -60,10 +53,24 @@ public class MyClientAppModule : AbpModule
} }
```` ````
`RemoteServiceOptions` is used to configure endpoints for remote services (This example sets the default endpoint while you can have different service endpoints used by different clients. See the "Multiple Remote Service Endpoint" section).
`AddHttpClientProxies` method gets an assembly, finds all service interfaces in the given assembly, creates and registers proxy classes. `AddHttpClientProxies` method gets an assembly, finds all service interfaces in the given assembly, creates and registers proxy classes.
### Endpoint Configuration
`RemoteServices` section in the `appsettings.json` file is used to get remote service address by default. Simplest configuration is shown below:
````
{
"RemoteServices": {
"Default": {
"BaseUrl": "http://localhost:53929/"
}
}
}
````
See the "RemoteServiceOptions" section below for more detailed configuration.
## Usage ## Usage
It's straightforward to use. Just inject the service interface in the client application code: It's straightforward to use. Just inject the service interface in the client application code:
@ -71,9 +78,9 @@ It's straightforward to use. Just inject the service interface in the client app
````csharp ````csharp
public class MyService : ITransientDependency public class MyService : ITransientDependency
{ {
private readonly IBookService _bookService; private readonly IBookAppService _bookService;
public MyService(IBookService bookService) public MyService(IBookAppService bookService)
{ {
_bookService = bookService; _bookService = bookService;
} }
@ -89,40 +96,34 @@ public class MyService : ITransientDependency
} }
```` ````
This sample injects the `IBookService` service interface defined above. The dynamic client proxy implementation makes an HTTP call whenever a service method is called by the client. This sample injects the `IBookAppService` service interface defined above. The dynamic client proxy implementation makes an HTTP call whenever a service method is called by the client.
## Configuration Details ### IHttpClientProxy Interface
### RemoteServiceOptions While you can inject `IBookAppService` like above to use the client proxy, you could inject `IHttpClientProxy<IBookAppService>` for a more explicit usage. In this case you will use the `Service` property of the `IHttpClientProxy<T>` interface.
While you can configure `RemoteServiceOptions` as the example shown above, you can let it to read from your `appsettings.json` file. Add a `RemoteServices` section to your `appsettings.json` file: ## Configuration
````json ### RemoteServiceOptions
{
"RemoteServices": {
"Default": {
"BaseUrl": "http://localhost:53929/"
}
}
}
````
Then you can pass your `IConfigurationRoot` instance directly to the `Configure<RemoteServiceOptions>()` method as shown below: `RemoteServiceOptions` is automatically set from the `appsettings.json` by default. Alternatively, you can use `Configure` method to set or override it. Example:
````csharp ````csharp
var configuration = new ConfigurationBuilder() public override void ConfigureServices(ServiceConfigurationContext context)
.SetBasePath(Directory.GetCurrentDirectory()) {
.AddJsonFile("appsettings.json") context.Services.Configure<RemoteServiceOptions>(options =>
.Build(); {
options.RemoteServices.Default =
context.Services.Configure<RemoteServiceOptions>(configuration); new RemoteServiceConfiguration("http://localhost:53929/");
});
//...
}
```` ````
This approach is useful since it's easy to change the configuration later without touching to the code. ### Multiple Remote Service Endpoints
#### Multiple Remote Service Endpoint The examples above have configured the "Default" remote service endpoint. You may have different endpoints for different services (as like in a microservice approach where each microservice has different endpoints). In this case, you can add other endpoints to your configuration file:
The examples above have configured the "Default" remote service endpoint. You may have different endpoints for different services (as like in a microservice approach where each microservice has different endpoint). In this case, you can add other endpoints to your configuration file:
````json ````json
{ {
@ -137,10 +138,6 @@ The examples above have configured the "Default" remote service endpoint. You ma
} }
```` ````
See the next section to learn how to use this new endpoint.
### AddHttpClientProxies Method
`AddHttpClientProxies` method can get an additional parameter for the remote service name. Example: `AddHttpClientProxies` method can get an additional parameter for the remote service name. Example:
````csharp ````csharp
@ -150,4 +147,19 @@ context.Services.AddHttpClientProxies(
); );
```` ````
`remoteServiceName` parameter matches the service endpoint configured via `RemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint. `remoteServiceName` parameter matches the service endpoint configured via `RemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint.
### As Default Services
When you create a service proxy for `IBookAppService`, you can directly inject the `IBookAppService` to use the proxy client (as shown in the usage section). You can pass `asDefaultServices: false` to the `AddHttpClientProxies` method to disable this feature.
````csharp
context.Services.AddHttpClientProxies(
typeof(BookStoreApplicationModule).Assembly,
asDefaultServices: false
);
````
Using `asDefaultServices: false` may only be needed if your application has already an implementation of the service and you do not want to override/replace the other implementation by your client proxy.
> If you disable `asDefaultServices`, you can only use `IHttpClientProxy<T>` interface to use the client proxies (see the related section above).

16
framework/Volo.Abp.sln

@ -220,7 +220,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Settings.Tests", "
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Http.Client.IdentityModel", "src\Volo.Abp.Http.Client.IdentityModel\Volo.Abp.Http.Client.IdentityModel.csproj", "{D211A446-38FA-4F97-9A95-1F004A0FFF69}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Http.Client.IdentityModel", "src\Volo.Abp.Http.Client.IdentityModel\Volo.Abp.Http.Client.IdentityModel.csproj", "{D211A446-38FA-4F97-9A95-1F004A0FFF69}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.IdentityModel", "src\Volo.Abp.IdentityModel\Volo.Abp.IdentityModel.csproj", "{64D99E19-EE25-465A-82E5-17B25F4C4E18}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.IdentityModel", "src\Volo.Abp.IdentityModel\Volo.Abp.IdentityModel.csproj", "{64D99E19-EE25-465A-82E5-17B25F4C4E18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Client", "src\Volo.Abp.AspNetCore.Mvc.Client\Volo.Abp.AspNetCore.Mvc.Client.csproj", "{E803DDB8-81EA-454B-9A66-9C2941100B67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Contracts", "src\Volo.Abp.AspNetCore.Mvc.Contracts\Volo.Abp.AspNetCore.Mvc.Contracts.csproj", "{88F6D091-CA16-4B71-9499-8D5B8FA2E712}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -628,6 +632,14 @@ Global
{64D99E19-EE25-465A-82E5-17B25F4C4E18}.Debug|Any CPU.Build.0 = Debug|Any CPU {64D99E19-EE25-465A-82E5-17B25F4C4E18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64D99E19-EE25-465A-82E5-17B25F4C4E18}.Release|Any CPU.ActiveCfg = Release|Any CPU {64D99E19-EE25-465A-82E5-17B25F4C4E18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64D99E19-EE25-465A-82E5-17B25F4C4E18}.Release|Any CPU.Build.0 = Release|Any CPU {64D99E19-EE25-465A-82E5-17B25F4C4E18}.Release|Any CPU.Build.0 = Release|Any CPU
{E803DDB8-81EA-454B-9A66-9C2941100B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E803DDB8-81EA-454B-9A66-9C2941100B67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E803DDB8-81EA-454B-9A66-9C2941100B67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E803DDB8-81EA-454B-9A66-9C2941100B67}.Release|Any CPU.Build.0 = Release|Any CPU
{88F6D091-CA16-4B71-9499-8D5B8FA2E712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88F6D091-CA16-4B71-9499-8D5B8FA2E712}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88F6D091-CA16-4B71-9499-8D5B8FA2E712}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88F6D091-CA16-4B71-9499-8D5B8FA2E712}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -735,6 +747,8 @@ Global
{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403} = {447C8A77-E5F0-4538-8687-7383196D04EA} {5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{D211A446-38FA-4F97-9A95-1F004A0FFF69} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {D211A446-38FA-4F97-9A95-1F004A0FFF69} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{64D99E19-EE25-465A-82E5-17B25F4C4E18} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {64D99E19-EE25-465A-82E5-17B25F4C4E18} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{E803DDB8-81EA-454B-9A66-9C2941100B67} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{88F6D091-CA16-4B71-9499-8D5B8FA2E712} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

22
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.AspNetCore.Mvc.Client</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc.Client</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.Contracts\Volo.Abp.AspNetCore.Mvc.Contracts.csproj" />
<ProjectReference Include="..\Volo.Abp.Caching\Volo.Abp.Caching.csproj" />
<ProjectReference Include="..\Volo.Abp.Http.Client\Volo.Abp.Http.Client.csproj" />
</ItemGroup>
</Project>

26
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs

@ -0,0 +1,26 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Caching;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
[DependsOn(
typeof(AbpHttpClientModule),
typeof(AbpAspNetCoreMvcContractsModule),
typeof(AbpCachingModule)
)]
public class AbpAspNetCoreMvcClientModule : AbpModule
{
public const string RemoteServiceName = "AbpMvcClient";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(
typeof(AbpAspNetCoreMvcContractsModule).Assembly,
RemoteServiceName,
asDefaultServices: false
);
}
}
}

65
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/CachedApplicationConfigurationClient.cs

@ -0,0 +1,65 @@
using System;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.Users;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
public class CachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
{
public IHttpContextAccessor HttpContextAccessor { get; set; }
protected IHttpClientProxy<IAbpApplicationConfigurationAppService> Proxy { get; }
protected ICurrentUser CurrentUser { get; }
protected IDistributedCache<ApplicationConfigurationDto> Cache { get; }
public CachedApplicationConfigurationClient(
IDistributedCache<ApplicationConfigurationDto> cache,
IHttpClientProxy<IAbpApplicationConfigurationAppService> proxy,
ICurrentUser currentUser,
IHttpContextAccessor httpContextAccessor)
{
Proxy = proxy;
CurrentUser = currentUser;
HttpContextAccessor = httpContextAccessor;
Cache = cache;
}
public async Task<ApplicationConfigurationDto> GetAsync()
{
var cacheKey = CreateCacheKey();
var httpContext = HttpContextAccessor?.HttpContext;
if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
{
return configuration;
}
configuration = await Cache.GetOrAddAsync(
CreateCacheKey(),
async () => await Proxy.Service.GetAsync(),
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
}
);
if (httpContext != null)
{
httpContext.Items[cacheKey] = configuration;
}
return configuration;
}
protected virtual string CreateCacheKey()
{
return $"ApplicationConfiguration_{CurrentUser.Id?.ToString("N") ?? "Anonymous"}";
}
}
}

10
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs

@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
public interface ICachedApplicationConfigurationClient
{
Task<ApplicationConfigurationDto> GetAsync();
}
}

32
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs

@ -0,0 +1,32 @@
using System.Security.Claims;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
public class RemotePermissionChecker : IPermissionChecker, ITransientDependency
{
protected ICachedApplicationConfigurationClient ConfigurationClient { get; }
public RemotePermissionChecker(ICachedApplicationConfigurationClient configurationClient)
{
ConfigurationClient = configurationClient;
}
public async Task<PermissionGrantInfo> CheckAsync(string name)
{
var configuration = await ConfigurationClient.GetAsync();
return new PermissionGrantInfo(
name,
configuration.Auth.GrantedPolicies.ContainsKey(name)
);
}
public Task<PermissionGrantInfo> CheckAsync(ClaimsPrincipal claimsPrincipal, string name)
{
return CheckAsync(name);
}
}
}

20
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.AspNetCore.Mvc.Contracts</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc.Contracts</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Ddd.Application\Volo.Abp.Ddd.Application.csproj" />
</ItemGroup>
</Project>

13
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs

@ -0,0 +1,13 @@
using Volo.Abp.Application;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc
{
[DependsOn(
typeof(AbpDddApplicationModule)
)]
public class AbpAspNetCoreMvcContractsModule : AbpModule
{
}
}

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs → framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs

@ -1,7 +1,9 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
[Serializable]
public class ApplicationAuthConfigurationDto public class ApplicationAuthConfigurationDto
{ {
public Dictionary<string, bool> Policies { get; set; } public Dictionary<string, bool> Policies { get; set; }

7
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs → framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs

@ -1,9 +1,14 @@
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations using System;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
[Serializable]
public class ApplicationConfigurationDto public class ApplicationConfigurationDto
{ {
public ApplicationLocalizationConfigurationDto Localization { get; set; } public ApplicationLocalizationConfigurationDto Localization { get; set; }
public ApplicationAuthConfigurationDto Auth { get; set; } public ApplicationAuthConfigurationDto Auth { get; set; }
public CurrentUserDto CurrentUser { get; set; }
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs → framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs

@ -1,7 +1,9 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
[Serializable]
public class ApplicationLocalizationConfigurationDto public class ApplicationLocalizationConfigurationDto
{ {
public Dictionary<string, Dictionary<string, string>> Values { get; set; } public Dictionary<string, Dictionary<string, string>> Values { get; set; }

16
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs

@ -0,0 +1,16 @@
using System;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{
[Serializable]
public class CurrentUserDto
{
public bool IsAuthenticated { get; set; }
public Guid? Id { get; set; }
public Guid? TenantId { get; set; }
public string UserName { get; set; }
}
}

3
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IApplicationConfigurationBuilder.cs → framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs

@ -1,8 +1,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
public interface IApplicationConfigurationBuilder public interface IAbpApplicationConfigurationAppService : IApplicationService
{ {
Task<ApplicationConfigurationDto> GetAsync(); Task<ApplicationConfigurationDto> GetAsync();
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs

@ -158,7 +158,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
pagerInfo + pagerInfo +
" <div class=\"col-sm-12 col-md-7\">\r\n" + " <div class=\"col-sm-12 col-md-7\">\r\n" +
" <nav aria-label=\"Page navigation\">\r\n" + " <nav aria-label=\"Page navigation\">\r\n" +
" <ul class=\"pagination justify-localizationKey-end\">"; " <ul class=\"pagination justify-content-end\">";
} }
protected virtual string GetClosingTags(TagHelperContext context, TagHelperOutput output) protected virtual string GetClosingTags(TagHelperContext context, TagHelperOutput output)

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj

@ -15,8 +15,8 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.ApiVersioning.Abstractions\Volo.Abp.ApiVersioning.Abstractions.csproj" /> <ProjectReference Include="..\Volo.Abp.ApiVersioning.Abstractions\Volo.Abp.ApiVersioning.Abstractions.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.Contracts\Volo.Abp.AspNetCore.Mvc.Contracts.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore\Volo.Abp.AspNetCore.csproj" /> <ProjectReference Include="..\Volo.Abp.AspNetCore\Volo.Abp.AspNetCore.csproj" />
<ProjectReference Include="..\Volo.Abp.Ddd.Application\Volo.Abp.Ddd.Application.csproj" />
<ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> <ProjectReference Include="..\Volo.Abp.Localization\Volo.Abp.Localization.csproj" />
<ProjectReference Include="..\Volo.Abp.UI\Volo.Abp.UI.csproj" /> <ProjectReference Include="..\Volo.Abp.UI\Volo.Abp.UI.csproj" />
</ItemGroup> </ItemGroup>

15
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -16,23 +15,23 @@ using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.ApiVersioning; using Volo.Abp.ApiVersioning;
using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc.Conventions; using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.AspNetCore.Mvc.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.VirtualFileSystem; using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.Http;
using Volo.Abp.Http.Modeling; using Volo.Abp.Http.Modeling;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.UI; using Volo.Abp.UI;
namespace Volo.Abp.AspNetCore.Mvc namespace Volo.Abp.AspNetCore.Mvc
{ {
[DependsOn(typeof(AbpAspNetCoreModule))] [DependsOn(
[DependsOn(typeof(AbpLocalizationModule))] typeof(AbpAspNetCoreModule),
[DependsOn(typeof(AbpApiVersioningAbstractionsModule))] typeof(AbpLocalizationModule),
[DependsOn(typeof(AbpDddApplicationModule))] typeof(AbpApiVersioningAbstractionsModule),
[DependsOn(typeof(AbpUiModule))] typeof(AbpAspNetCoreMvcContractsModule),
typeof(AbpUiModule)
)]
public class AbpAspNetCoreMvcModule : AbpModule public class AbpAspNetCoreMvcModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)

40
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder.cs → framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

@ -1,43 +1,59 @@
using System; using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization; using Volo.Abp.Authorization;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Users;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
public class ApplicationConfigurationBuilder : IApplicationConfigurationBuilder, ITransientDependency public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApplicationConfigurationAppService
{ {
private readonly AbpLocalizationOptions _localizationOptions; private readonly AbpLocalizationOptions _localizationOptions;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly IAbpAuthorizationPolicyProvider _abpAuthorizationPolicyProvider; private readonly IAbpAuthorizationPolicyProvider _abpAuthorizationPolicyProvider;
private readonly IAuthorizationService _authorizationService; private readonly IAuthorizationService _authorizationService;
private readonly ICurrentUser _currentUser;
public ApplicationConfigurationBuilder( public AbpApplicationConfigurationAppService(
IOptions<AbpLocalizationOptions> localizationOptions, IOptions<AbpLocalizationOptions> localizationOptions,
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider, IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
IAuthorizationService authorizationService) IAuthorizationService authorizationService,
ICurrentUser currentUser)
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
_abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider; _abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider;
_authorizationService = authorizationService; _authorizationService = authorizationService;
_currentUser = currentUser;
_localizationOptions = localizationOptions.Value; _localizationOptions = localizationOptions.Value;
} }
public async Task<ApplicationConfigurationDto> GetAsync() //TODO: Test, at least with a simple Get public async Task<ApplicationConfigurationDto> GetAsync()
{ {
//TODO: Optimize & cache..? //TODO: Optimize & cache..?
return new ApplicationConfigurationDto return new ApplicationConfigurationDto
{ {
Auth = await GetAuthConfig(), Auth = await GetAuthConfig(),
Localization = GetLocalizationConfig() Localization = GetLocalizationConfig(),
CurrentUser = GetCurrentUser()
};
}
protected virtual CurrentUserDto GetCurrentUser()
{
return new CurrentUserDto
{
IsAuthenticated = _currentUser.IsAuthenticated,
Id = _currentUser.Id,
TenantId = _currentUser.TenantId,
UserName = _currentUser.UserName
}; };
} }
@ -66,7 +82,9 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
var dictionary = new Dictionary<string, string>(); var dictionary = new Dictionary<string, string>();
var localizer = _serviceProvider.GetRequiredService(typeof(IStringLocalizer<>).MakeGenericType(resource.ResourceType)) as IStringLocalizer; var localizer = _serviceProvider.GetRequiredService(
typeof(IStringLocalizer<>).MakeGenericType(resource.ResourceType)
) as IStringLocalizer;
foreach (var localizedString in localizer.GetAllStrings()) foreach (var localizedString in localizer.GetAllStrings())
{ {

13
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs

@ -4,19 +4,20 @@ using Microsoft.AspNetCore.Mvc;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
{ {
[Route("api/abp/application-configuration")] [Route("api/abp/application-configuration")]
public class AbpApplicationConfigurationController : AbpController public class AbpApplicationConfigurationController : AbpController, IAbpApplicationConfigurationAppService
{ {
private readonly IApplicationConfigurationBuilder _configurationBuilder; private readonly IAbpApplicationConfigurationAppService _applicationConfigurationAppService;
public AbpApplicationConfigurationController(IApplicationConfigurationBuilder configurationBuilder) public AbpApplicationConfigurationController(
IAbpApplicationConfigurationAppService applicationConfigurationAppService)
{ {
_configurationBuilder = configurationBuilder; _applicationConfigurationAppService = applicationConfigurationAppService;
} }
[HttpGet] [HttpGet]
public Task<ApplicationConfigurationDto> Get() public Task<ApplicationConfigurationDto> GetAsync()
{ {
return _configurationBuilder.GetAsync(); return _applicationConfigurationAppService.GetAsync();
} }
} }
} }

8
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs

@ -12,14 +12,14 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
[DisableAuditing] [DisableAuditing]
public class AbpApplicationConfigurationScriptController : AbpController public class AbpApplicationConfigurationScriptController : AbpController
{ {
private readonly IApplicationConfigurationBuilder _configurationBuilder; private readonly IAbpApplicationConfigurationAppService _configurationAppService;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
public AbpApplicationConfigurationScriptController( public AbpApplicationConfigurationScriptController(
IApplicationConfigurationBuilder configurationBuilder, IAbpApplicationConfigurationAppService configurationAppService,
IJsonSerializer jsonSerializer) IJsonSerializer jsonSerializer)
{ {
_configurationBuilder = configurationBuilder; _configurationAppService = configurationAppService;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
} }
@ -28,7 +28,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
public async Task<string> Get() public async Task<string> Get()
{ {
return CreateAbpExtendScript( return CreateAbpExtendScript(
await _configurationBuilder.GetAsync() await _configurationAppService.GetAsync()
); );
} }

1
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs

@ -79,6 +79,7 @@ namespace Volo.Abp.AspNetCore.Mvc
return; return;
} }
Logger.LogDebug($"ActionApiDescriptionModel.Create: {controllerModel.ControllerName}.{uniqueMethodName}");
var actionModel = controllerModel.AddAction(uniqueMethodName, ActionApiDescriptionModel.Create( var actionModel = controllerModel.AddAction(uniqueMethodName, ActionApiDescriptionModel.Create(
uniqueMethodName, uniqueMethodName,
method, method,

4
framework/src/Volo.Abp.Authorization/Microsoft/Extensions/DependencyInjection/AbpAuthorizationServiceCollectionExtensions.cs

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization; using System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Authorization; using Volo.Abp.Authorization;
using Volo.Abp.Authorization.Permissions; using Volo.Abp.Authorization.Permissions;
@ -8,6 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static class AbpAuthorizationServiceCollectionExtensions public static class AbpAuthorizationServiceCollectionExtensions
{ {
//TODO: Remove this and use AddAlwaysAllowAuthorization //TODO: Remove this and use AddAlwaysAllowAuthorization
[Obsolete("Use AddAlwaysAllowAuthorization instead")]
public static IServiceCollection AddAlwaysAllowPermissionChecker(this IServiceCollection services) public static IServiceCollection AddAlwaysAllowPermissionChecker(this IServiceCollection services)
{ {
return services.Replace(ServiceDescriptor.Singleton<IPermissionChecker, AlwaysAllowPermissionChecker>()); return services.Replace(ServiceDescriptor.Singleton<IPermissionChecker, AlwaysAllowPermissionChecker>());

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs

@ -6,7 +6,7 @@ namespace Volo.Abp.Authorization.Permissions
/// <summary> /// <summary>
/// Always allows for any permission. /// Always allows for any permission.
/// ///
/// Use IServiceCollection.AddAlwaysAllowPermissionChecker() to replace /// Use IServiceCollection.AddAlwaysAllowAuthorization() to replace
/// IPermissionChecker with this class. This is useful for tests. /// IPermissionChecker with this class. This is useful for tests.
/// </summary> /// </summary>
public class AlwaysAllowPermissionChecker : IPermissionChecker public class AlwaysAllowPermissionChecker : IPermissionChecker

6
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs

@ -1,4 +1,4 @@
using System.Net.Http.Headers; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -26,9 +26,7 @@ namespace Volo.Abp.Http.Client.IdentityModel
if (accessToken != null) if (accessToken != null)
{ {
//TODO: "Bearer" should be configurable context.Client.SetBearerToken(accessToken);
context.Client.DefaultRequestHeaders.Authorization
= new AuthenticationHeaderValue("Bearer", accessToken);
} }
else else
{ {

114
framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Castle.DynamicProxy; using Castle.DynamicProxy;
using JetBrains.Annotations;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Castle.DynamicProxy; using Volo.Abp.Castle.DynamicProxy;
using Volo.Abp.Http.Client; using Volo.Abp.Http.Client;
@ -13,8 +14,28 @@ namespace Microsoft.Extensions.DependencyInjection
{ {
private static readonly ProxyGenerator ProxyGeneratorInstance = new ProxyGenerator(); private static readonly ProxyGenerator ProxyGeneratorInstance = new ProxyGenerator();
public static IServiceCollection AddHttpClientProxies(this IServiceCollection services, Assembly assembly, string remoteServiceName = RemoteServiceConfigurationDictionary.DefaultName) /// <summary>
/// Registers HTTP Client Proxies for all public interfaces
/// extend the <see cref="IRemoteService"/> interface in the
/// given <paramref name="assembly"/>.
/// </summary>
/// <param name="services">Service collection</param>
/// <param name="assembly">The assembly containing the service interfaces</param>
/// <param name="remoteServiceConfigurationName">
/// The name of the remote service configuration to be used by the HTTP Client proxies.
/// See <see cref="RemoteServiceOptions"/>.
/// </param>
/// <param name="asDefaultServices">
/// True, to register the HTTP client proxy as the default implementation for the services.
/// </param>
public static IServiceCollection AddHttpClientProxies(
[NotNull] this IServiceCollection services,
[NotNull] Assembly assembly,
[NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultServices = true)
{ {
Check.NotNull(services, nameof(assembly));
//TODO: Make a configuration option and add remoteServiceName inside it! //TODO: Make a configuration option and add remoteServiceName inside it!
//TODO: Add option to change type filter //TODO: Add option to change type filter
@ -24,36 +45,101 @@ namespace Microsoft.Extensions.DependencyInjection
foreach (var serviceType in serviceTypes) foreach (var serviceType in serviceTypes)
{ {
services.AddHttpClientProxy(serviceType, remoteServiceName); services.AddHttpClientProxy(
serviceType,
remoteServiceConfigurationName,
asDefaultServices
);
} }
return services; return services;
} }
public static IServiceCollection AddHttpClientProxy<T>(this IServiceCollection services, string remoteServiceName = RemoteServiceConfigurationDictionary.DefaultName) /// <summary>
/// Registers HTTP Client Proxy for given service type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">Type of the service</typeparam>
/// <param name="services">Service collection</param>
/// <param name="remoteServiceConfigurationName">
/// The name of the remote service configuration to be used by the HTTP Client proxy.
/// See <see cref="RemoteServiceOptions"/>.
/// </param>
/// <param name="asDefaultService">
/// True, to register the HTTP client proxy as the default implementation for the service <typeparamref name="T"/>.
/// </param>
public static IServiceCollection AddHttpClientProxy<T>(
[NotNull] this IServiceCollection services,
[NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultService = true)
{ {
return services.AddHttpClientProxy(typeof(T), remoteServiceName); return services.AddHttpClientProxy(
typeof(T),
remoteServiceConfigurationName,
asDefaultService
);
} }
public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, Type type, string remoteServiceName = RemoteServiceConfigurationDictionary.DefaultName) /// <summary>
/// Registers HTTP Client Proxy for given service <paramref name="type"/>.
/// </summary>
/// <param name="services">Service collection</param>
/// <param name="type">Type of the service</param>
/// <param name="remoteServiceConfigurationName">
/// The name of the remote service configuration to be used by the HTTP Client proxy.
/// See <see cref="RemoteServiceOptions"/>.
/// </param>
/// <param name="asDefaultService">
/// True, to register the HTTP client proxy as the default implementation for the service <paramref name="type"/>.
/// </param>
public static IServiceCollection AddHttpClientProxy(
[NotNull] this IServiceCollection services,
[NotNull] Type type,
[NotNull] string remoteServiceConfigurationName = RemoteServiceConfigurationDictionary.DefaultName,
bool asDefaultService = true)
{ {
Check.NotNull(services, nameof(services));
Check.NotNull(type, nameof(type));
Check.NotNullOrWhiteSpace(remoteServiceConfigurationName, nameof(remoteServiceConfigurationName));
services.Configure<AbpHttpClientOptions>(options => services.Configure<AbpHttpClientOptions>(options =>
{ {
options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(type, remoteServiceName); options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(type, remoteServiceConfigurationName);
}); });
var interceptorType = typeof(DynamicHttpProxyInterceptor<>).MakeGenericType(type); var interceptorType = typeof(DynamicHttpProxyInterceptor<>).MakeGenericType(type);
services.AddTransient(interceptorType); services.AddTransient(interceptorType);
var interceptorAdapterType = typeof(CastleAbpInterceptorAdapter<>).MakeGenericType(interceptorType); var interceptorAdapterType = typeof(CastleAbpInterceptorAdapter<>).MakeGenericType(interceptorType);
return services.AddTransient(
type, if (asDefaultService)
serviceProvider => ProxyGeneratorInstance {
.CreateInterfaceProxyWithoutTarget( services.AddTransient(
type, type,
(IInterceptor) serviceProvider.GetRequiredService(interceptorAdapterType) serviceProvider => ProxyGeneratorInstance
) .CreateInterfaceProxyWithoutTarget(
); type,
(IInterceptor)serviceProvider.GetRequiredService(interceptorAdapterType)
)
);
}
services.AddTransient(
typeof(IHttpClientProxy<>).MakeGenericType(type),
serviceProvider =>
{
var service = ProxyGeneratorInstance
.CreateInterfaceProxyWithoutTarget(
type,
(IInterceptor) serviceProvider.GetRequiredService(interceptorAdapterType)
);
return Activator.CreateInstance(
typeof(HttpClientProxy<>).MakeGenericType(type),
service
);
});
return services;
} }
} }
} }

12
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/HttpClientProxy.cs

@ -0,0 +1,12 @@
namespace Volo.Abp.Http.Client.DynamicProxying
{
public class HttpClientProxy<TRemoteService> : IHttpClientProxy<TRemoteService>
{
public TRemoteService Service { get; }
public HttpClientProxy(TRemoteService service)
{
Service = service;
}
}
}

7
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IHttpClientProxy.cs

@ -0,0 +1,7 @@
namespace Volo.Abp.Http.Client.DynamicProxying
{
public interface IHttpClientProxy<out TRemoteService>
{
TRemoteService Service { get; }
}
}

2
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationBuilder_Tests.cs

@ -9,7 +9,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
[Fact] [Fact]
public async Task ApplicationConfigurationBuilder_GetAsync() public async Task ApplicationConfigurationBuilder_GetAsync()
{ {
var applicationConfigurationBuilder = GetRequiredService<IApplicationConfigurationBuilder>(); var applicationConfigurationBuilder = GetRequiredService<IAbpApplicationConfigurationAppService>();
var config = await applicationConfigurationBuilder.GetAsync(); var config = await applicationConfigurationBuilder.GetAsync();

2
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestBaseModule.cs

@ -14,7 +14,7 @@ namespace Volo.Abp.Identity
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAlwaysAllowPermissionChecker(); context.Services.AddAlwaysAllowAuthorization();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

8
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs

@ -67,14 +67,14 @@ namespace Volo.Abp.IdentityServer.ApiResources
UserClaims.Clear(); UserClaims.Clear();
} }
public virtual void RemoveClaim(string name, string type) public virtual void RemoveClaim(string type)
{ {
UserClaims.RemoveAll(r => r.Name == name && r.Type == type); UserClaims.RemoveAll(r => r.Type == type);
} }
public virtual ApiScopeClaim FindClaim(string name, string type) public virtual ApiScopeClaim FindClaim(string type)
{ {
return UserClaims.FirstOrDefault(r => r.Name == name && r.Type == type); return UserClaims.FirstOrDefault(r => r.Name == Name && r.Type == type);
} }
public override object[] GetKeys() public override object[] GetKeys()

9
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceDataSeeder.cs

@ -13,7 +13,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
public IdentityResourceDataSeeder( public IdentityResourceDataSeeder(
IIdentityResourceRepository identityResourceRepository, IIdentityResourceRepository identityResourceRepository,
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
IIdentityClaimTypeRepository claimTypeRepository) IIdentityClaimTypeRepository claimTypeRepository)
{ {
IdentityResourceRepository = identityResourceRepository; IdentityResourceRepository = identityResourceRepository;
@ -23,13 +23,14 @@ namespace Volo.Abp.IdentityServer.IdentityResources
public virtual async Task CreateStandardResourcesAsync() public virtual async Task CreateStandardResourcesAsync()
{ {
var resources = new IdentityServer4.Models.IdentityResource[] var resources = new[]
{ {
new IdentityServer4.Models.IdentityResources.OpenId(), new IdentityServer4.Models.IdentityResources.OpenId(),
new IdentityServer4.Models.IdentityResources.Profile(), new IdentityServer4.Models.IdentityResources.Profile(),
new IdentityServer4.Models.IdentityResources.Email(), new IdentityServer4.Models.IdentityResources.Email(),
new IdentityServer4.Models.IdentityResources.Address(), new IdentityServer4.Models.IdentityResources.Address(),
new IdentityServer4.Models.IdentityResources.Phone() new IdentityServer4.Models.IdentityResources.Phone(),
new IdentityServer4.Models.IdentityResource("role", "Roles of the user", new[] {"role"})
}; };
foreach (var resource in resources) foreach (var resource in resources)
@ -42,7 +43,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
await AddIdentityResourceIfNotExistsAsync(resource); await AddIdentityResourceIfNotExistsAsync(resource);
} }
} }
protected virtual async Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource) protected virtual async Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource)
{ {
if (await IdentityResourceRepository.FindByNameAsync(resource.Name) != null) if (await IdentityResourceRepository.FindByNameAsync(resource.Name) != null)

2
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestBaseModule.cs

@ -14,7 +14,7 @@ namespace Volo.Abp.IdentityServer
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAlwaysAllowPermissionChecker(); context.Services.AddAlwaysAllowAuthorization();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

20
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -50,14 +50,30 @@ namespace Volo.Abp.IdentityServer
private void AddIdentityResources() private void AddIdentityResources()
{ {
_identityResourceRepository.Insert(new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1")); var identityResource = new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1")
{
Description = nameof(Client.Description),
DisplayName = nameof(IdentityResource.DisplayName)
};
identityResource.AddUserClaim(nameof(ApiResourceClaim.Type));
_identityResourceRepository.Insert(identityResource);
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2")); _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2"));
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3")); _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3"));
} }
private void AddApiResources() private void AddApiResources()
{ {
_apiResourceRepository.Insert(new ApiResource(_testData.ApiResource1Id, "NewApiResource1")); var apiResource = new ApiResource(_testData.ApiResource1Id, "NewApiResource1");
apiResource.Description = nameof(apiResource.Description);
apiResource.DisplayName = nameof(apiResource.DisplayName);
apiResource.AddScope(nameof(ApiScope.Name));
apiResource.AddUserClaim(nameof(ApiResourceClaim.Type));
apiResource.AddSecret(nameof(ApiSecret.Value));
_apiResourceRepository.Insert(apiResource);
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource2")); _apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource2"));
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource3")); _apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource3"));
} }

2
modules/tenant-management/test/Volo.Abp.TenantManagement.Application.Tests/Volo/Abp/TenantManagement/AbpTenantManagementApplicationTestModule.cs

@ -11,7 +11,7 @@ namespace Volo.Abp.TenantManagement
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAlwaysAllowPermissionChecker(); context.Services.AddAlwaysAllowAuthorization();
} }
} }
} }

4
nupkg/common.ps1

@ -28,6 +28,8 @@ $projects = (
"framework/src/Volo.Abp.AspNetCore.Authentication.OAuth", "framework/src/Volo.Abp.AspNetCore.Authentication.OAuth",
"framework/src/Volo.Abp.AspNetCore.MultiTenancy", "framework/src/Volo.Abp.AspNetCore.MultiTenancy",
"framework/src/Volo.Abp.AspNetCore.Mvc", "framework/src/Volo.Abp.AspNetCore.Mvc",
"framework/src/Volo.Abp.AspNetCore.Mvc.Contracts",
"framework/src/Volo.Abp.AspNetCore.Mvc.Client",
"framework/src/Volo.Abp.AspNetCore.Mvc.UI", "framework/src/Volo.Abp.AspNetCore.Mvc.UI",
"framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", "framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap",
"framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling", "framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling",
@ -57,7 +59,7 @@ $projects = (
"framework/src/Volo.Abp.EntityFrameworkCore.MySQL", "framework/src/Volo.Abp.EntityFrameworkCore.MySQL",
"framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql", "framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql",
"framework/src/Volo.Abp.EventBus", "framework/src/Volo.Abp.EventBus",
"framework/src/Volo.Abp.EventBus.Distributed.RabbitMQ", "framework/src/Volo.Abp.EventBus.RabbitMQ",
"framework/src/Volo.Abp.Guids", "framework/src/Volo.Abp.Guids",
"framework/src/Volo.Abp.HangFire", "framework/src/Volo.Abp.HangFire",
"framework/src/Volo.Abp.Http", "framework/src/Volo.Abp.Http",

2
samples/BookStore/src/Acme.BookStore.Application/Acme.BookStore.Application.csproj

@ -7,7 +7,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" /> <ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
<PackageReference Include="Volo.Abp.Identity.Application" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Identity.Application" Version="0.12.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

2
samples/BookStore/src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Identity.Domain" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Identity.Domain" Version="0.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" />
</ItemGroup> </ItemGroup>

8
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj

@ -12,10 +12,10 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" /> <ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="0.11.0" /> <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="0.12.0" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="0.11.0" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="0.12.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="0.11.0" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="0.12.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

460
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20190111135616_ABP_v0_11_Upgrade.Designer.cs

@ -0,0 +1,460 @@
// <auto-generated />
using System;
using Acme.BookStore.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Acme.BookStore.Migrations
{
[DbContext(typeof(BookStoreDbContext))]
[Migration("20190111135616_ABP_v0_11_Upgrade")]
partial class ABP_v0_11_Upgrade
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Acme.BookStore.Book", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128);
b.Property<float>("Price");
b.Property<DateTime>("PublishDate");
b.Property<byte>("Type");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
b.Property<string>("Description")
.HasMaxLength(256);
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsStatic");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256);
b.Property<string>("Regex")
.HasMaxLength(512);
b.Property<string>("RegexDescription")
.HasMaxLength(128);
b.Property<bool>("Required");
b.Property<int>("ValueType");
b.HasKey("Id");
b.ToTable("AbpClaimTypes");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDefault")
.HasColumnName("IsDefault");
b.Property<bool>("IsPublic")
.HasColumnName("IsPublic");
b.Property<bool>("IsStatic")
.HasColumnName("IsStatic");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.IsRequired()
.HasMaxLength(256);
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("NormalizedName");
b.ToTable("AbpRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType")
.IsRequired()
.HasMaxLength(256);
b.Property<string>("ClaimValue")
.HasMaxLength(1024);
b.Property<Guid>("RoleId");
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AbpRoleClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount")
.ValueGeneratedOnAdd()
.HasColumnName("AccessFailedCount")
.HasDefaultValue(0);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime");
b.Property<string>("Email")
.HasColumnName("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed")
.ValueGeneratedOnAdd()
.HasColumnName("EmailConfirmed")
.HasDefaultValue(false);
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<bool>("LockoutEnabled")
.ValueGeneratedOnAdd()
.HasColumnName("LockoutEnabled")
.HasDefaultValue(false);
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("Name")
.HasColumnName("Name")
.HasMaxLength(64);
b.Property<string>("NormalizedEmail")
.HasColumnName("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.IsRequired()
.HasColumnName("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash")
.HasColumnName("PasswordHash")
.HasMaxLength(256);
b.Property<string>("PhoneNumber")
.HasColumnName("PhoneNumber")
.HasMaxLength(16);
b.Property<bool>("PhoneNumberConfirmed")
.ValueGeneratedOnAdd()
.HasColumnName("PhoneNumberConfirmed")
.HasDefaultValue(false);
b.Property<string>("SecurityStamp")
.IsRequired()
.HasColumnName("SecurityStamp")
.HasMaxLength(256);
b.Property<string>("Surname")
.HasColumnName("Surname")
.HasMaxLength(64);
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId");
b.Property<bool>("TwoFactorEnabled")
.ValueGeneratedOnAdd()
.HasColumnName("TwoFactorEnabled")
.HasDefaultValue(false);
b.Property<string>("UserName")
.IsRequired()
.HasColumnName("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("Email");
b.HasIndex("NormalizedEmail");
b.HasIndex("NormalizedUserName");
b.HasIndex("UserName");
b.ToTable("AbpUsers");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType")
.IsRequired()
.HasMaxLength(256);
b.Property<string>("ClaimValue")
.HasMaxLength(1024);
b.Property<Guid?>("TenantId");
b.Property<Guid>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AbpUserClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<Guid>("UserId");
b.Property<string>("LoginProvider")
.HasMaxLength(64);
b.Property<string>("ProviderDisplayName")
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.IsRequired()
.HasMaxLength(196);
b.Property<Guid?>("TenantId");
b.HasKey("UserId", "LoginProvider");
b.HasIndex("LoginProvider", "ProviderKey");
b.ToTable("AbpUserLogins");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.Property<Guid>("UserId");
b.Property<Guid>("RoleId");
b.Property<Guid?>("TenantId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId", "UserId");
b.ToTable("AbpUserRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.Property<Guid>("UserId");
b.Property<string>("LoginProvider")
.HasMaxLength(64);
b.Property<string>("Name")
.HasMaxLength(128);
b.Property<Guid?>("TenantId");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AbpUserTokens");
});
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.IsRequired()
.HasMaxLength(64);
b.Property<string>("ProviderName")
.IsRequired()
.HasMaxLength(64);
b.Property<Guid?>("TenantId");
b.HasKey("Id");
b.HasIndex("Name", "ProviderName", "ProviderKey");
b.ToTable("AbpPermissionGrants");
});
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasMaxLength(64);
b.Property<string>("ProviderName")
.HasMaxLength(64);
b.Property<string>("Value")
.IsRequired()
.HasMaxLength(2048);
b.HasKey("Id");
b.HasIndex("Name", "ProviderName", "ProviderKey");
b.ToTable("AbpSettings");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany("Claims")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Claims")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Logins")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Tokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

42
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/20190111135616_ABP_v0_11_Upgrade.cs

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Acme.BookStore.Migrations
{
public partial class ABP_v0_11_Upgrade : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<bool>(
name: "IsDeleted",
table: "AbpUsers",
nullable: false,
defaultValue: false,
oldClrType: typeof(bool));
migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AbpUsers",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 256);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<bool>(
name: "IsDeleted",
table: "AbpUsers",
nullable: false,
oldClrType: typeof(bool),
oldDefaultValue: false);
migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AbpUsers",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldNullable: true);
}
}
}

44
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Migrations/BookStoreDbContextModelSnapshot.cs

@ -15,7 +15,7 @@ namespace Acme.BookStore.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846") .HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@ -25,18 +25,23 @@ namespace Acme.BookStore.Migrations
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken(); .IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime"); b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId"); b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime"); b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId"); b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
@ -166,17 +171,19 @@ namespace Acme.BookStore.Migrations
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .HasColumnName("ConcurrencyStamp");
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
b.Property<DateTime>("CreationTime"); b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId"); b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId"); b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime"); b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnName("Email") .HasColumnName("Email")
@ -190,11 +197,16 @@ namespace Acme.BookStore.Migrations
b.Property<string>("ExtraProperties") b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted"); b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime"); b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId"); b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<bool>("LockoutEnabled") b.Property<bool>("LockoutEnabled")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()

8
samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj

@ -27,10 +27,10 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Acme.BookStore.Application\Acme.BookStore.Application.csproj" /> <ProjectReference Include="..\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
<ProjectReference Include="..\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="0.11.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Autofac" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Identity.Web" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Identity.Web" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Account.Web" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Account.Web" Version="0.12.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

50
samples/BookStore/src/Acme.BookStore.Web/BookStoreWebModule.cs

@ -2,7 +2,6 @@
using Localization.Resources.AbpUi; using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Acme.BookStore.EntityFrameworkCore; using Acme.BookStore.EntityFrameworkCore;
using Acme.BookStore.Localization.BookStore; using Acme.BookStore.Localization.BookStore;
@ -17,7 +16,6 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.Identity.Web; using Volo.Abp.Identity.Web;
@ -56,42 +54,40 @@ namespace Acme.BookStore
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.BuildConfiguration(); var configuration = context.Services.GetConfiguration();
ConfigureDatabaseServices(context.Services, configuration); ConfigureDatabaseServices();
ConfigureAutoMapper(context.Services); ConfigureAutoMapper();
ConfigureVirtualFileSystem(context.Services, hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices(context.Services); ConfigureLocalizationServices();
ConfigureNavigationServices(context.Services); ConfigureNavigationServices();
ConfigureAutoApiControllers(context.Services); ConfigureAutoApiControllers();
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
context.Services.AddAssemblyOf<BookStoreWebModule>(); context.Services.AddAssemblyOf<BookStoreWebModule>();
} }
private static void ConfigureDatabaseServices(IServiceCollection services, IConfigurationRoot configuration) private void ConfigureDatabaseServices()
{ {
services.Configure<DbConnectionOptions>(options => Configure<AbpDbContextOptions>(options =>
{ {
options.ConnectionStrings.Default = configuration.GetConnectionString("Default"); options.UseSqlServer();
}); });
services.Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
} }
private static void ConfigureAutoMapper(IServiceCollection services) private void ConfigureAutoMapper()
{ {
services.Configure<AbpAutoMapperOptions>(options => Configure<AbpAutoMapperOptions>(options =>
{ {
options.AddProfile<BookStoreWebAutoMapperProfile>(); options.AddProfile<BookStoreWebAutoMapperProfile>();
}); });
} }
private static void ConfigureVirtualFileSystem(IServiceCollection services, IHostingEnvironment hostingEnvironment) private void ConfigureVirtualFileSystem(IHostingEnvironment hostingEnvironment)
{ {
if (hostingEnvironment.IsDevelopment()) if (hostingEnvironment.IsDevelopment())
{ {
services.Configure<VirtualFileSystemOptions>(options => Configure<VirtualFileSystemOptions>(options =>
{ {
options.FileSets.ReplaceEmbeddedByPyhsical<BookStoreDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Acme.BookStore.Domain", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPyhsical<BookStoreDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Acme.BookStore.Domain", Path.DirectorySeparatorChar)));
@ -99,9 +95,9 @@ namespace Acme.BookStore
} }
} }
private static void ConfigureLocalizationServices(IServiceCollection services) private void ConfigureLocalizationServices()
{ {
services.Configure<AbpLocalizationOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.Resources options.Resources
.Get<BookStoreResource>() .Get<BookStoreResource>()
@ -115,23 +111,23 @@ namespace Acme.BookStore
}); });
} }
private static void ConfigureNavigationServices(IServiceCollection services) private void ConfigureNavigationServices()
{ {
services.Configure<NavigationOptions>(options => Configure<NavigationOptions>(options =>
{ {
options.MenuContributors.Add(new BookStoreMenuContributor()); options.MenuContributors.Add(new BookStoreMenuContributor());
}); });
} }
private static void ConfigureAutoApiControllers(IServiceCollection services) private void ConfigureAutoApiControllers()
{ {
services.Configure<AbpAspNetCoreMvcOptions>(options => Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly); options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly);
}); });
} }
private static void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureSwaggerServices(IServiceCollection services)
{ {
services.AddSwaggerGen( services.AddSwaggerGen(
options => options =>
@ -180,7 +176,7 @@ namespace Acme.BookStore
SeedDatabase(context); SeedDatabase(context);
} }
private static void SeedDatabase(ApplicationInitializationContext context) private void SeedDatabase(ApplicationInitializationContext context)
{ {
AsyncHelper.RunSync(async () => AsyncHelper.RunSync(async () =>
{ {

4
samples/BookStore/test/Acme.BookStore.Application.Tests/Acme.BookStore.Application.Tests.csproj

@ -8,8 +8,8 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" /> <ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
<ProjectReference Include="..\..\src\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\src\Acme.BookStore.EntityFrameworkCore\Acme.BookStore.EntityFrameworkCore.csproj" />
<PackageReference Include="Volo.Abp.TestBase" Version="0.11.0" /> <PackageReference Include="Volo.Abp.TestBase" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Autofac" Version="0.12.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

4
samples/BookStore/test/Acme.BookStore.ConsoleApiClient/Acme.BookStore.ConsoleApiClient.csproj

@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Autofac" Version="0.12.0" />
<PackageReference Include="Volo.Abp.Http.Client" Version="0.11.0" /> <PackageReference Include="Volo.Abp.Http.Client" Version="0.12.0" />
<ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" /> <ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
</ItemGroup> </ItemGroup>

11
samples/BookStore/test/Acme.BookStore.ConsoleApiClient/ConsoleApiClientModule.cs

@ -1,6 +1,4 @@
using System.IO; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.Http.Client; using Volo.Abp.Http.Client;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -16,13 +14,6 @@ namespace Acme.BookStore.ConsoleApiClient
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
context.Services.Configure<RemoteServiceOptions>(configuration);
context.Services.AddHttpClientProxies( context.Services.AddHttpClientProxies(
typeof(BookStoreApplicationModule).Assembly typeof(BookStoreApplicationModule).Assembly
); );

2
samples/BookStore/test/Acme.BookStore.Web.Tests/Acme.BookStore.Web.Tests.csproj

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<ProjectReference Include="..\Acme.BookStore.Application.Tests\Acme.BookStore.Application.Tests.csproj" /> <ProjectReference Include="..\Acme.BookStore.Application.Tests\Acme.BookStore.Application.Tests.csproj" />
<ProjectReference Include="..\..\src\Acme.BookStore.Web\Acme.BookStore.Web.csproj" /> <ProjectReference Include="..\..\src\Acme.BookStore.Web\Acme.BookStore.Web.csproj" />
<PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.11.0" /> <PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.12.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

2
templates/module/test/MyCompanyName.MyProjectName.TestBase/MyCompanyName/MyProjectName/MyProjectNameTestBaseModule.cs

@ -16,7 +16,7 @@ namespace MyCompanyName.MyProjectName
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAlwaysAllowPermissionChecker(); context.Services.AddAlwaysAllowAuthorization();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

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

@ -3,7 +3,6 @@ using System.Linq;
using Localization.Resources.AbpUi; using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using MyCompanyName.MyProjectName.EntityFrameworkCore; using MyCompanyName.MyProjectName.EntityFrameworkCore;
using MyCompanyName.MyProjectName.Localization.MyProjectName; using MyCompanyName.MyProjectName.Localization.MyProjectName;
@ -21,7 +20,6 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.Identity.Web; using Volo.Abp.Identity.Web;
using Volo.Abp.Localization; using Volo.Abp.Localization;
@ -66,40 +64,38 @@ namespace MyCompanyName.MyProjectName
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
ConfigureDatabaseServices(context.Services, configuration); ConfigureDatabaseServices();
ConfigureAutoMapper(context.Services); ConfigureAutoMapper();
ConfigureVirtualFileSystem(context.Services, hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureLocalizationServices(context.Services); ConfigureLocalizationServices();
ConfigureNavigationServices(context.Services); ConfigureNavigationServices();
ConfigureAutoApiControllers(context.Services); ConfigureAutoApiControllers();
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
} }
private static void ConfigureDatabaseServices(IServiceCollection services, IConfigurationRoot configuration) private void ConfigureDatabaseServices()
{ {
services.Configure<DbConnectionOptions>(options => //<TEMPLATE-REMOVE IF-NOT='EntityFrameworkCore'>
Configure<AbpDbContextOptions>(options =>
{ {
options.ConnectionStrings.Default = configuration.GetConnectionString("Default"); options.UseSqlServer();
}); });
//<TEMPLATE-REMOVE IF-NOT='EntityFrameworkCore'>
services.Configure<AbpDbContextOptions>(options => { options.UseSqlServer(); });
//</TEMPLATE-REMOVE> //</TEMPLATE-REMOVE>
} }
private static void ConfigureAutoMapper(IServiceCollection services) private void ConfigureAutoMapper()
{ {
services.Configure<AbpAutoMapperOptions>(options => Configure<AbpAutoMapperOptions>(options =>
{ {
options.AddProfile<MyProjectNameWebAutoMapperProfile>(); options.AddProfile<MyProjectNameWebAutoMapperProfile>();
}); });
} }
private static void ConfigureVirtualFileSystem(IServiceCollection services, IHostingEnvironment hostingEnvironment) private void ConfigureVirtualFileSystem(IHostingEnvironment hostingEnvironment)
{ {
if (hostingEnvironment.IsDevelopment()) if (hostingEnvironment.IsDevelopment())
{ {
services.Configure<VirtualFileSystemOptions>(options => Configure<VirtualFileSystemOptions>(options =>
{ {
options.FileSets.ReplaceEmbeddedByPyhsical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPyhsical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar)));
//<TEMPLATE-REMOVE> //<TEMPLATE-REMOVE>
@ -116,9 +112,9 @@ namespace MyCompanyName.MyProjectName
} }
} }
private static void ConfigureLocalizationServices(IServiceCollection services) private void ConfigureLocalizationServices()
{ {
services.Configure<AbpLocalizationOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.Resources options.Resources
.Get<MyProjectNameResource>() .Get<MyProjectNameResource>()
@ -134,23 +130,23 @@ namespace MyCompanyName.MyProjectName
}); });
} }
private static void ConfigureNavigationServices(IServiceCollection services) private void ConfigureNavigationServices()
{ {
services.Configure<NavigationOptions>(options => Configure<NavigationOptions>(options =>
{ {
options.MenuContributors.Add(new MyProjectNameMenuContributor()); options.MenuContributors.Add(new MyProjectNameMenuContributor());
}); });
} }
private static void ConfigureAutoApiControllers(IServiceCollection services) private void ConfigureAutoApiControllers()
{ {
services.Configure<AbpAspNetCoreMvcOptions>(options => Configure<AbpAspNetCoreMvcOptions>(options =>
{ {
options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly);
}); });
} }
private static void ConfigureSwaggerServices(IServiceCollection services) private void ConfigureSwaggerServices(IServiceCollection services)
{ {
services.AddSwaggerGen( services.AddSwaggerGen(
options => options =>

7
templates/service/host/IdentityServerHost/IdentityServerDataSeeder.cs

@ -79,11 +79,8 @@ namespace IdentityServerHost
client.AddScope("roles"); client.AddScope("roles");
client.AddScope("unique_name"); client.AddScope("unique_name");
client.AddGrantTypes(new List<string> client.AddGrantType("client_credentials");
{ client.AddGrantType("password");
"client_credentials",
"password"
});
client.AddSecret("K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols="); client.AddSecret("K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=");

2
templates/service/test/MyCompanyName.MyProjectName.TestBase/MyCompanyName/MyProjectName/MyProjectNameTestBaseModule.cs

@ -16,7 +16,7 @@ namespace MyCompanyName.MyProjectName
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAlwaysAllowPermissionChecker(); context.Services.AddAlwaysAllowAuthorization();
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

Loading…
Cancel
Save