Browse Source

Merge pull request #1 from abpframework/master

pull/725/head
Nokecy 7 years ago
committed by GitHub
parent
commit
fc26b6d20e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      common.props
  2. 16
      docs/en/Tutorials/AspNetCore-Mvc/Part-I.md
  3. 18
      framework/Volo.Abp.sln
  4. 46
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs
  5. 33
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
  6. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs
  7. 39
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
  8. 13
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/IAbpTagHelperLocalizer.cs
  9. 27
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
  10. 22
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo.Abp.Http.Client.IdentityModel.csproj
  11. 14
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/AbpHttpClientIdentityModelModule.cs
  12. 56
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs
  13. 24
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/RemoteServiceConfigurationExtensions.cs
  14. 23
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/HttpContextAccessTokenProvider.cs
  15. 9
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IAccessTokenProvider.cs
  16. 9
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IRemoteServiceHttpClientAuthenticator.cs
  17. 14
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/NullRemoteServiceHttpClientAuthenticator.cs
  18. 23
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/RemoteServiceHttpClientAuthenticateContext.cs
  19. 37
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
  20. 4
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/RequestPayloadBuilder.cs
  21. 28
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs
  22. 11
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs
  23. 1
      framework/src/Volo.Abp.Http/Volo.Abp.Http.csproj
  24. 1
      framework/src/Volo.Abp.Http/Volo/Abp/Http/MimeTypes.cs
  25. 21
      framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj
  26. 15
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs
  27. 9
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IIdentityModelHttpClientAuthenticator.cs
  28. 93
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs
  29. 15
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfigurationDictionary.cs
  30. 12
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientOptions.cs
  31. 27
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpClientAuthenticateContext.cs
  32. 96
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs
  33. 6
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
  34. 26
      framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantSettingValueProvider.cs
  35. 7
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs
  36. 4
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
  37. 2
      modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj
  38. 2
      modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs
  39. 2
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/Create.cshtml.cs
  40. 2
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/Index.cshtml
  41. 1
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/en.json
  42. 1
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/tr.json
  43. 7
      modules/identity/Volo.Abp.Identity.sln
  44. 21
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.csproj
  45. 38
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs
  46. 10
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreOptions.cs
  47. 0
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs
  48. 6
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimValueType.cs
  49. 11
      modules/identity/src/Volo.Abp.Identity.Domain/Microsoft/Extensions/DependencyInjection/AbpIdentityServiceCollectionExtensions.cs
  50. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj
  51. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs
  52. 13
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIDentityClaimTypeRepository.cs
  53. 14
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdenityClaimTypeManager.cs
  54. 26
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs
  55. 15
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs
  56. 35
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs
  57. 5
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs
  58. 4
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs
  59. 40
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  60. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaim.cs
  61. 18
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScope.cs
  62. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs
  63. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs
  64. 110
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  65. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaim.cs
  66. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOrigin.cs
  67. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantType.cs
  68. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestriction.cs
  69. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUri.cs
  70. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientProperty.cs
  71. 5
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUri.cs
  72. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs
  73. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceDataSeeder.cs
  74. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs
  75. 7
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaim.cs
  76. 24
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs
  77. 77
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceDataSeeder.cs
  78. 26
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs
  79. 69
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs
  80. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs
  81. 25
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs
  82. 12
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs
  83. 14
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs
  84. 35
      modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  85. 26
      modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserSettingValueProvider.cs
  86. 5
      nupkg/common.ps1
  87. 2
      samples/BookStore/src/Acme.BookStore.Application/Acme.BookStore.Application.csproj
  88. 2
      samples/BookStore/src/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj
  89. 8
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/Acme.BookStore.EntityFrameworkCore.csproj
  90. 4
      samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreDbContext.cs
  91. 8
      samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj
  92. 4
      samples/BookStore/test/Acme.BookStore.Application.Tests/Acme.BookStore.Application.Tests.csproj
  93. 4
      samples/BookStore/test/Acme.BookStore.ConsoleApiClient/Acme.BookStore.ConsoleApiClient.csproj
  94. 2
      samples/BookStore/test/Acme.BookStore.Web.Tests/Acme.BookStore.Web.Tests.csproj
  95. 31
      templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.Designer.cs
  96. 12
      templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.cs
  97. 29
      templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs
  98. 2
      templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj
  99. 32
      templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.Designer.cs
  100. 12
      templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.cs

2
common.props

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

16
docs/en/Tutorials/AspNetCore-Mvc/Part-I.md

@ -85,21 +85,7 @@ EF Core requires you to relate entities with your DbContext. The easiest way to
public class BookStoreDbContext : AbpDbContext<BookStoreDbContext>
{
public DbSet<Book> Book { get; set; }
public BookStoreDbContext(DbContextOptions<BookStoreDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Book>(
b => b.ConfigureExtraProperties()
);
}
...
}
````

18
framework/Volo.Abp.sln

@ -214,9 +214,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.EntityFrameworkCor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Localization.Abstractions", "src\Volo.Abp.Localization.Abstractions\Volo.Abp.Localization.Abstractions.csproj", "{20513A4E-FAC7-4106-8976-5D79A3BDFED1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Security.Tests", "test\Volo.Abp.Security.Tests\Volo.Abp.Security.Tests.csproj", "{7CE07034-7E02-4C78-B981-F1039412CA5E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Security.Tests", "test\Volo.Abp.Security.Tests\Volo.Abp.Security.Tests.csproj", "{7CE07034-7E02-4C78-B981-F1039412CA5E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Settings.Tests", "test\Volo.Abp.Settings.Tests\Volo.Abp.Settings.Tests.csproj", "{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Settings.Tests", "test\Volo.Abp.Settings.Tests\Volo.Abp.Settings.Tests.csproj", "{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403}"
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.IdentityModel", "src\Volo.Abp.IdentityModel\Volo.Abp.IdentityModel.csproj", "{64D99E19-EE25-465A-82E5-17B25F4C4E18}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -616,6 +620,14 @@ Global
{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F3A2D1E-EA89-40A7-8D2F-FB4EB2092403}.Release|Any CPU.Build.0 = Release|Any CPU
{D211A446-38FA-4F97-9A95-1F004A0FFF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D211A446-38FA-4F97-9A95-1F004A0FFF69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D211A446-38FA-4F97-9A95-1F004A0FFF69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D211A446-38FA-4F97-9A95-1F004A0FFF69}.Release|Any CPU.Build.0 = Release|Any CPU
{64D99E19-EE25-465A-82E5-17B25F4C4E18}.Debug|Any CPU.ActiveCfg = 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.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -721,6 +733,8 @@ Global
{20513A4E-FAC7-4106-8976-5D79A3BDFED1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{7CE07034-7E02-4C78-B981-F1039412CA5E} = {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}
{64D99E19-EE25-465A-82E5-17B25F4C4E18} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

46
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.Localization;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers
{
public class AbpTagHelperLocalizer : IAbpTagHelperLocalizer
{
private readonly IStringLocalizerFactory _stringLocalizerFactory;
private readonly AbpMvcDataAnnotationsLocalizationOptions _options;
public AbpTagHelperLocalizer(IOptions<AbpMvcDataAnnotationsLocalizationOptions> options, IStringLocalizerFactory stringLocalizerFactory)
{
_stringLocalizerFactory = stringLocalizerFactory;
_options = options.Value;
}
public string GetLocalizedText(string text, ModelExplorer explorer)
{
var localizer = GetStringLocalizer(explorer);
return localizer == null ? text : localizer[text].Value;
}
public IStringLocalizer GetLocalizer(ModelExplorer explorer)
{
return GetStringLocalizer(explorer);
}
private IStringLocalizer GetStringLocalizer(ModelExplorer explorer)
{
IStringLocalizer localizer = null;
var resourceType = _options.AssemblyResources.GetOrDefault(explorer.Container.ModelType.Assembly);
if (resourceType != null)
{
localizer = _stringLocalizerFactory.Create(resourceType);
}
return localizer;
}
}
}

33
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

@ -17,15 +17,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{
private readonly IHtmlGenerator _generator;
private readonly HtmlEncoder _encoder;
private readonly IStringLocalizerFactory _stringLocalizerFactory;
private readonly AbpMvcDataAnnotationsLocalizationOptions _options;
private readonly IAbpTagHelperLocalizer _tagHelperLocalizer;
public AbpInputTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IOptions<AbpMvcDataAnnotationsLocalizationOptions> options, IStringLocalizerFactory stringLocalizerFactory)
public AbpInputTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IAbpTagHelperLocalizer tagHelperLocalizer)
{
_generator = generator;
_encoder = encoder;
_stringLocalizerFactory = stringLocalizerFactory;
_options = options.Value;
_tagHelperLocalizer = tagHelperLocalizer;
}
public override void Process(TagHelperContext context, TagHelperOutput output)
@ -52,6 +50,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
output.TagName = "div";
LeaveOnlyGroupAttributes(context, output);
output.Attributes.AddClass(isCheckbox ? "form-check" : "form-group");
output.Attributes.AddClass(isCheckbox ? "mb-2" : "");
output.Content.SetHtmlContent(output.Content.GetContent() + innerHtml);
}
}
@ -189,7 +188,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
if (attribute != null)
{
inputTagHelperOutput.Attributes.Add("placeholder", LocalizeText(attribute.Value));
var placeholderLocalized = _tagHelperLocalizer.GetLocalizedText(attribute.Value, TagHelper.AspFor.ModelExplorer);
inputTagHelperOutput.Attributes.Add("placeholder", placeholderLocalized);
}
}
@ -207,20 +208,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return;
}
inputTagHelperOutput.Attributes.Add("aria-describedby", LocalizeText(idAttr.Value + "InfoText"));
}
protected virtual string LocalizeText(string text)
{
IStringLocalizer localizer = null;
var resourceType = _options.AssemblyResources.GetOrDefault(TagHelper.AspFor.ModelExplorer.Container.ModelType.Assembly);
if (resourceType != null)
{
localizer = _stringLocalizerFactory.Create(resourceType);
}
var infoText = _tagHelperLocalizer.GetLocalizedText(idAttr.Value + "InfoText", TagHelper.AspFor.ModelExplorer);
return localizer == null? text: localizer[text].Value;
inputTagHelperOutput.Attributes.Add("aria-describedby", infoText);
}
protected virtual bool IsInputCheckbox(TagHelperContext context, TagHelperOutput output, TagHelperAttributeList attributes)
@ -269,7 +259,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return "";
}
string text = "";
var text = "";
if (!string.IsNullOrEmpty(TagHelper.InfoText))
{
@ -289,9 +279,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
}
var idAttr = inputTag.Attributes.FirstOrDefault(a => a.Name == "id");
var localizedText = _tagHelperLocalizer.GetLocalizedText(text, TagHelper.AspFor.ModelExplorer);
return "<small id=\""+ idAttr?.Value + "InfoText\" class=\"form-text text-muted\">" +
LocalizeText(text) +
localizedText +
"</small>";
}

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpRadioInputTagHelperService.cs

@ -14,13 +14,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{
public class AbpRadioInputTagHelperService : AbpTagHelperService<AbpRadioInputTagHelper>
{
private readonly AbpMvcDataAnnotationsLocalizationOptions _options;
private readonly IStringLocalizerFactory _stringLocalizerFactory;
private readonly IAbpTagHelperLocalizer _tagHelperLocalizer;
public AbpRadioInputTagHelperService(IOptions<AbpMvcDataAnnotationsLocalizationOptions> options, IStringLocalizerFactory stringLocalizerFactory)
public AbpRadioInputTagHelperService(IAbpTagHelperLocalizer tagHelperLocalizer)
{
_options = options.Value;
_stringLocalizerFactory = stringLocalizerFactory;
_tagHelperLocalizer = tagHelperLocalizer;
}
public override void Process(TagHelperContext context, TagHelperOutput output)
@ -93,13 +91,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual List<SelectListItem> GetSelectItemsFromEnum(TagHelperContext context, TagHelperOutput output, ModelExplorer explorer)
{
IStringLocalizer localizer = null;
var resourceType = _options.AssemblyResources.GetOrDefault(explorer.Container.ModelType.Assembly);
if (resourceType != null)
{
localizer = _stringLocalizerFactory.Create(resourceType);
}
var localizer = _tagHelperLocalizer.GetLocalizer(explorer);
var selectItems = explorer.Metadata.IsEnum ? explorer.ModelType.GetTypeInfo().GetMembers(BindingFlags.Public | BindingFlags.Static)
.Select((t, i) => new SelectListItem { Value = i.ToString(), Text = GetLocalizedPropertyName(localizer, explorer.ModelType, t.Name) }).ToList() : null;

39
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs

@ -20,15 +20,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{
private readonly IHtmlGenerator _generator;
private readonly HtmlEncoder _encoder;
private readonly IStringLocalizerFactory _stringLocalizerFactory;
private readonly AbpMvcDataAnnotationsLocalizationOptions _options;
private readonly IAbpTagHelperLocalizer _tagHelperLocalizer;
public AbpSelectTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IOptions<AbpMvcDataAnnotationsLocalizationOptions> options, IStringLocalizerFactory stringLocalizerFactory)
public AbpSelectTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IAbpTagHelperLocalizer tagHelperLocalizer)
{
_generator = generator;
_encoder = encoder;
_stringLocalizerFactory = stringLocalizerFactory;
_options = options.Value;
_tagHelperLocalizer = tagHelperLocalizer;
}
public override void Process(TagHelperContext context, TagHelperOutput output)
@ -154,12 +152,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return;
}
inputTagHelperOutput.Attributes.Add("aria-describedby", LocalizeText(idAttr.Value + "InfoText"));
var infoText = _tagHelperLocalizer.GetLocalizedText(idAttr.Value + "InfoText", TagHelper.AspFor.ModelExplorer);
inputTagHelperOutput.Attributes.Add("aria-describedby", infoText);
}
protected virtual string GetInfoAsHtml(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag)
{
string text = "";
var text = "";
if (!string.IsNullOrEmpty(TagHelper.InfoText))
{
@ -179,35 +179,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
}
var idAttr = inputTag.Attributes.FirstOrDefault(a => a.Name == "id");
var localizedText = _tagHelperLocalizer.GetLocalizedText(text, TagHelper.AspFor.ModelExplorer);
return "<small id=\"" + idAttr?.Value + "InfoText\" class=\"form-text text-muted\">" +
LocalizeText(text) +
localizedText +
"</small>";
}
protected virtual string LocalizeText(string text)
{
var localizer = GetLocalizer();
return localizer == null ? text : localizer[text].Value;
}
protected virtual IStringLocalizer GetLocalizer()
{
IStringLocalizer localizer = null;
var resourceType = _options.AssemblyResources.GetOrDefault(TagHelper.AspFor.ModelExplorer.Container.ModelType.Assembly);
if (resourceType != null)
{
localizer = _stringLocalizerFactory.Create(resourceType);
}
return localizer;
}
protected virtual List<SelectListItem> GetSelectItemsFromEnum(TagHelperContext context, TagHelperOutput output, ModelExplorer explorer)
{
var localizer = GetLocalizer();
var localizer = _tagHelperLocalizer.GetLocalizer(explorer);
var selectItems = explorer.Metadata.IsEnum ? explorer.ModelType.GetTypeInfo().GetMembers(BindingFlags.Public | BindingFlags.Static)
.Select((t, i) => new SelectListItem { Value = i.ToString(), Text = GetLocalizedPropertyName(localizer, explorer.ModelType, t.Name) }).ToList() : null;

13
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/IAbpTagHelperLocalizer.cs

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.Localization;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers
{
public interface IAbpTagHelperLocalizer : ITransientDependency
{
string GetLocalizedText(string text, ModelExplorer explorer);
IStringLocalizer GetLocalizer(ModelExplorer explorer);
}
}

27
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

@ -86,7 +86,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (autoSave)
{
await DbContext.SaveChangesAsync(cancellationToken);
await DbContext.SaveChangesAsync(GetCancellationToken(cancellationToken));
}
return updatedEntity;
@ -108,7 +108,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (autoSave)
{
await DbContext.SaveChangesAsync(cancellationToken);
await DbContext.SaveChangesAsync(GetCancellationToken(cancellationToken));
}
}
@ -122,8 +122,8 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override async Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
{
return includeDetails
? await WithDetails().ToListAsync(cancellationToken)
: await DbSet.ToListAsync(cancellationToken);
? await WithDetails().ToListAsync(GetCancellationToken(cancellationToken))
: await DbSet.ToListAsync(GetCancellationToken(cancellationToken));
}
public override long GetCount()
@ -133,7 +133,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await DbSet.LongCountAsync(cancellationToken);
return await DbSet.LongCountAsync(GetCancellationToken(cancellationToken));
}
protected override IQueryable<TEntity> GetQueryable()
@ -153,7 +153,10 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool autoSave = false, CancellationToken cancellationToken = default)
{
var entities = await GetQueryable().Where(predicate).ToListAsync(GetCancellationToken(cancellationToken));
var entities = await GetQueryable()
.Where(predicate)
.ToListAsync(GetCancellationToken(cancellationToken));
foreach (var entity in entities)
{
DbSet.Remove(entity);
@ -161,7 +164,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (autoSave)
{
await DbContext.SaveChangesAsync(cancellationToken);
await DbContext.SaveChangesAsync(GetCancellationToken(cancellationToken));
}
}
@ -171,7 +174,10 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
CancellationToken cancellationToken = default)
where TProperty : class
{
await DbContext.Entry(entity).Collection(propertyExpression).LoadAsync(GetCancellationToken(cancellationToken));
await DbContext
.Entry(entity)
.Collection(propertyExpression)
.LoadAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task EnsurePropertyLoadedAsync<TProperty>(
@ -180,7 +186,10 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
CancellationToken cancellationToken = default)
where TProperty : class
{
await DbContext.Entry(entity).Reference(propertyExpression).LoadAsync(GetCancellationToken(cancellationToken));
await DbContext
.Entry(entity)
.Reference(propertyExpression)
.LoadAsync(GetCancellationToken(cancellationToken));
}
public override IQueryable<TEntity> WithDetails()

22
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo.Abp.Http.Client.IdentityModel.csproj

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

14
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/AbpHttpClientIdentityModelModule.cs

@ -0,0 +1,14 @@
using Volo.Abp.IdentityModel;
using Volo.Abp.Modularity;
namespace Volo.Abp.Http.Client.IdentityModel
{
[DependsOn(
typeof(AbpHttpClientModule),
typeof(AbpIdentityModelModule)
)]
public class AbpHttpClientIdentityModelModule : AbpModule
{
}
}

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

@ -0,0 +1,56 @@
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.Authentication;
using Volo.Abp.IdentityModel;
namespace Volo.Abp.Http.Client.IdentityModel
{
[Dependency(ReplaceServices = true)]
public class IdentityModelRemoteServiceHttpClientAuthenticator : IRemoteServiceHttpClientAuthenticator, ITransientDependency
{
public IHttpContextAccessor HttpContextAccessor { get; set; }
protected IIdentityModelHttpClientAuthenticator IdentityModelHttpClientAuthenticator { get; }
public IdentityModelRemoteServiceHttpClientAuthenticator(IIdentityModelHttpClientAuthenticator identityModelHttpClientAuthenticator)
{
IdentityModelHttpClientAuthenticator = identityModelHttpClientAuthenticator;
}
public async Task Authenticate(RemoteServiceHttpClientAuthenticateContext context)
{
var accessToken = await GetAccessTokenFromHttpContextOrNullAsync();
if (accessToken != null)
{
//TODO: "Bearer" should be configurable
context.Client.DefaultRequestHeaders.Authorization
= new AuthenticationHeaderValue("Bearer", accessToken);
}
else
{
await IdentityModelHttpClientAuthenticator.Authenticate(
new IdentityModelHttpClientAuthenticateContext(
context.Client,
context.RemoteService.GetIdentityClient()
)
);
}
}
protected virtual async Task<string> GetAccessTokenFromHttpContextOrNullAsync()
{
//TODO: What if the access_token in the current Http Request is not usable for this client?
var httpContext = HttpContextAccessor?.HttpContext;
if (httpContext == null)
{
return null;
}
return await httpContext.GetTokenAsync("access_token");
}
}
}

24
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/RemoteServiceConfigurationExtensions.cs

@ -0,0 +1,24 @@
using System.Collections.Generic;
using JetBrains.Annotations;
namespace Volo.Abp.Http.Client
{
public static class RemoteServiceConfigurationExtensions
{
public const string IdentityClient = "IdentityClient";
[CanBeNull]
public static string GetIdentityClient([NotNull] this RemoteServiceConfiguration configuration)
{
Check.NotNullOrEmpty(configuration, nameof(configuration));
return configuration.GetOrDefault(IdentityClient);
}
public static RemoteServiceConfiguration SetIdentityClient([NotNull] this RemoteServiceConfiguration configuration, [CanBeNull] string value)
{
configuration[IdentityClient] = value;
return configuration;
}
}
}

23
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/HttpContextAccessTokenProvider.cs

@ -1,23 +0,0 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Http.Client.Authentication
{
public class HttpContextAccessTokenProvider : IAccessTokenProvider, ISingletonDependency
{
public IHttpContextAccessor HttpContextAccessor { get; set; }
public async Task<string> GetOrNullAsync()
{
var httpContext = HttpContextAccessor?.HttpContext;
if (httpContext == null)
{
return null;
}
return await httpContext.GetTokenAsync("access_token");
}
}
}

9
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IAccessTokenProvider.cs

@ -1,9 +0,0 @@
using System.Threading.Tasks;
namespace Volo.Abp.Http.Client.Authentication
{
public interface IAccessTokenProvider //TODO: Not sure if this class should be here
{
Task<string> GetOrNullAsync();
}
}

9
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/IRemoteServiceHttpClientAuthenticator.cs

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Volo.Abp.Http.Client.Authentication
{
public interface IRemoteServiceHttpClientAuthenticator
{
Task Authenticate(RemoteServiceHttpClientAuthenticateContext context);
}
}

14
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/NullRemoteServiceHttpClientAuthenticator.cs

@ -0,0 +1,14 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Http.Client.Authentication
{
[Dependency(TryRegister = true)]
public class NullRemoteServiceHttpClientAuthenticator : IRemoteServiceHttpClientAuthenticator, ISingletonDependency
{
public Task Authenticate(RemoteServiceHttpClientAuthenticateContext context)
{
return Task.CompletedTask;
}
}
}

23
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Authentication/RemoteServiceHttpClientAuthenticateContext.cs

@ -0,0 +1,23 @@
using System.Net.Http;
namespace Volo.Abp.Http.Client.Authentication
{
public class RemoteServiceHttpClientAuthenticateContext
{
public HttpClient Client { get; }
public HttpRequestMessage Request { get; }
public RemoteServiceConfiguration RemoteService { get; }
public RemoteServiceHttpClientAuthenticateContext(
HttpClient client,
HttpRequestMessage request,
RemoteServiceConfiguration remoteService)
{
Client = client;
Request = request;
RemoteService = remoteService;
}
}
}

37
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
@ -28,7 +27,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying
private readonly RemoteServiceOptions _remoteServiceOptions;
private readonly AbpHttpClientOptions _clientOptions;
private readonly IJsonSerializer _jsonSerializer;
private readonly IAccessTokenProvider _accessTokenProvider;
private readonly IRemoteServiceHttpClientAuthenticator _clientAuthenticator;
static DynamicHttpProxyInterceptor()
{
@ -43,12 +42,12 @@ namespace Volo.Abp.Http.Client.DynamicProxying
IOptionsSnapshot<RemoteServiceOptions> remoteServiceOptions,
IApiDescriptionFinder apiDescriptionFinder,
IJsonSerializer jsonSerializer,
IAccessTokenProvider accessTokenProvider)
IRemoteServiceHttpClientAuthenticator clientAuthenticator)
{
_httpClientFactory = httpClientFactory;
_apiDescriptionFinder = apiDescriptionFinder;
_jsonSerializer = jsonSerializer;
_accessTokenProvider = accessTokenProvider;
_clientAuthenticator = clientAuthenticator;
_clientOptions = clientOptions.Value;
_remoteServiceOptions = remoteServiceOptions.Value;
}
@ -110,11 +109,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying
using (var client = _httpClientFactory.Create())
{
var clientConfig = _clientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) ?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}.");
var remoteServiceConfig = _remoteServiceOptions.RemoteServices.GetConfigurationOrDefault(clientConfig.RemoteServiceName);
var baseUrl = GetBaseUrl(clientConfig);
var action = await _apiDescriptionFinder.FindActionAsync(baseUrl, typeof(TService), invocation.Method);
var action = await _apiDescriptionFinder.FindActionAsync(remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
var apiVersion = GetApiVersionInfo(action);
var url = baseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var url = remoteServiceConfig.BaseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url)
{
@ -123,12 +122,13 @@ namespace Volo.Abp.Http.Client.DynamicProxying
AddHeaders(invocation, action, requestMessage, apiVersion);
var accessToken = await _accessTokenProvider.GetOrNullAsync();
if (accessToken != null)
{
//TODO: "Bearer" should not be static.
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
}
await _clientAuthenticator.Authenticate(
new RemoteServiceHttpClientAuthenticateContext(
client,
requestMessage,
remoteServiceConfig
)
);
var response = await client.SendAsync(requestMessage);
@ -174,8 +174,8 @@ namespace Volo.Abp.Http.Client.DynamicProxying
if (!apiVersion.Version.IsNullOrEmpty())
{
//TODO: What about other media types?
requestMessage.Headers.Add("accept", $"text/plain; v={apiVersion.Version}");
requestMessage.Headers.Add("accept", $"application/json; v={apiVersion.Version}");
requestMessage.Headers.Add("accept", $"{MimeTypes.Text.Plain}; v={apiVersion.Version}");
requestMessage.Headers.Add("accept", $"{MimeTypes.Application.Json}; v={apiVersion.Version}");
requestMessage.Headers.Add("api-version", apiVersion.Version);
}
@ -191,13 +191,6 @@ namespace Volo.Abp.Http.Client.DynamicProxying
}
}
private string GetBaseUrl(DynamicHttpClientProxyConfig config)
{
return _remoteServiceOptions.RemoteServices.GetOrDefault(config.RemoteServiceName)?.BaseUrl
?? _remoteServiceOptions.RemoteServices.Default?.BaseUrl
?? throw new AbpException($"Could not find Base URL for {typeof(TService).FullName}.");
}
private string GetConfiguredApiVersion()
{
var clientConfig = _clientOptions.HttpClientProxies.GetOrDefault(typeof(TService))

4
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/RequestPayloadBuilder.cs

@ -17,13 +17,13 @@ namespace Volo.Abp.Http.Client.DynamicProxying
var body = GenerateBody(action, methodArguments, jsonSerializer);
if (body != null)
{
return new StringContent(body, Encoding.UTF8, "application/json"); //TODO: application/json to a constant
return new StringContent(body, Encoding.UTF8, MimeTypes.Application.Json);
}
body = GenerateFormPostData(action, methodArguments);
if (body != null)
{
return new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded"); //TODO: application/x-www-form-urlencoded to a constant
return new StringContent(body, Encoding.UTF8, MimeTypes.Application.XWwwFormUrlencoded);
}
return null;

28
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs

@ -1,10 +1,26 @@
namespace Volo.Abp.Http.Client
using System.Collections.Generic;
namespace Volo.Abp.Http.Client
{
public class RemoteServiceConfiguration
public class RemoteServiceConfiguration : Dictionary<string, string>
{
public string BaseUrl { get; set; }
/// <summary>
/// Base Url.
/// </summary>
public string BaseUrl
{
get => this.GetOrDefault(nameof(BaseUrl));
set => this[BaseUrl] = value;
}
public string Version { get; set; }
/// <summary>
/// Version.
/// </summary>
public string Version
{
get => this.GetOrDefault(nameof(Version));
set => this[Version] = value;
}
public RemoteServiceConfiguration()
{
@ -13,8 +29,8 @@
public RemoteServiceConfiguration(string baseUrl, string version = null)
{
BaseUrl = baseUrl;
Version = version;
this[nameof(BaseUrl)] = baseUrl;
this[nameof(Version)] = version;
}
}
}

11
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs

@ -8,8 +8,15 @@ namespace Volo.Abp.Http.Client
public RemoteServiceConfiguration Default
{
get { return this.GetOrDefault(DefaultName); }
set { this[DefaultName] = value; }
get => this.GetOrDefault(DefaultName);
set => this[DefaultName] = value;
}
public RemoteServiceConfiguration GetConfigurationOrDefault(string name)
{
return this.GetOrDefault(name)
?? Default
?? throw new AbpException($"Remote service '{name}' was not found and there is no default configuration.");
}
}
}

1
framework/src/Volo.Abp.Http/Volo.Abp.Http.csproj

@ -14,7 +14,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Castle.Core\Volo.Abp.Castle.Core.csproj" />
<ProjectReference Include="..\Volo.Abp.Http.Abstractions\Volo.Abp.Http.Abstractions.csproj" />
<ProjectReference Include="..\Volo.Abp.Json\Volo.Abp.Json.csproj" />
</ItemGroup>

1
framework/src/Volo.Abp.Http/Volo/Abp/Http/MimeTypes.cs

@ -32,6 +32,7 @@ namespace Volo.Abp.Http
public const string XPkcs12 = "application/x-pkcs12";
public const string XShockwaveFlash = "application/x-shockwave-flash";
public const string XSilverlightApp = "application/x-silverlight-app";
public const string XWwwFormUrlencoded = "application/x-www-form-urlencoded";
public const string XhtmlXml = "application/xhtml+xml";
public const string Xml = "application/xml";
public const string XmlDtd = "application/xml-dtd";

21
framework/src/Volo.Abp.IdentityModel/Volo.Abp.IdentityModel.csproj

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.IdentityModel</AssemblyName>
<PackageId>Volo.Abp.IdentityModel</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IdentityModel" Version="3.10.4" />
<ProjectReference Include="..\Volo.Abp.Core\Volo.Abp.Core.csproj" />
</ItemGroup>
</Project>

15
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/AbpIdentityModelModule.cs

@ -0,0 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.IdentityModel
{
public class AbpIdentityModelModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<IdentityClientOptions>(configuration);
}
}
}

9
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IIdentityModelHttpClientAuthenticator.cs

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Volo.Abp.IdentityModel
{
public interface IIdentityModelHttpClientAuthenticator
{
Task Authenticate(IdentityModelHttpClientAuthenticateContext context);
}
}

93
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs

@ -0,0 +1,93 @@
using System.Collections.Generic;
using IdentityModel;
namespace Volo.Abp.IdentityModel
{
public class IdentityClientConfiguration : Dictionary<string, string>
{
/// <summary>
/// Possible values: "client_credentials" or "password".
/// Default value: "client_credentials".
/// </summary>
public string GrantType
{
get => this.GetOrDefault(nameof(GrantType));
set => this[GrantType] = value;
}
/// <summary>
/// Client Id.
/// </summary>
public string ClientId
{
get => this.GetOrDefault(nameof(ClientId));
set => this[ClientId] = value;
}
/// <summary>
/// Client secret (as plain text - without hashed).
/// </summary>
public string ClientSecret
{
get => this.GetOrDefault(nameof(ClientSecret));
set => this[ClientSecret] = value;
}
/// <summary>
/// User name.
/// Valid only if <see cref="GrantType"/> is "password".
/// </summary>
public string UserName
{
get => this.GetOrDefault(nameof(UserName));
set => this[UserName] = value;
}
/// <summary>
/// Password of the <see cref="UserName"/>.
/// Valid only if <see cref="GrantType"/> is "password".
/// </summary>
public string UserPassword
{
get => this.GetOrDefault(nameof(UserPassword));
set => this[UserPassword] = value;
}
/// <summary>
/// Authority.
/// </summary>
public string Authority
{
get => this.GetOrDefault(nameof(Authority));
set => this[Authority] = value;
}
/// <summary>
/// Scope.
/// </summary>
public string Scope
{
get => this.GetOrDefault(nameof(Scope));
set => this[Scope] = value;
}
public IdentityClientConfiguration()
{
}
public IdentityClientConfiguration(
string clientId,
string clientSecret,
string grantType = OidcConstants.GrantTypes.ClientCredentials,
string userName = null,
string userPassword = null)
{
this[nameof(ClientId)] = clientId;
this[nameof(ClientSecret)] = clientSecret;
this[nameof(GrantType)] = grantType;
this[nameof(UserName)] = userName;
this[nameof(UserPassword)] = userPassword;
}
}
}

15
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfigurationDictionary.cs

@ -0,0 +1,15 @@
using System.Collections.Generic;
namespace Volo.Abp.IdentityModel
{
public class IdentityClientConfigurationDictionary : Dictionary<string, IdentityClientConfiguration>
{
public const string DefaultName = "Default";
public IdentityClientConfiguration Default
{
get => this.GetOrDefault(DefaultName);
set => this[DefaultName] = value;
}
}
}

12
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientOptions.cs

@ -0,0 +1,12 @@
namespace Volo.Abp.IdentityModel
{
public class IdentityClientOptions
{
public IdentityClientConfigurationDictionary IdentityClients { get; set; }
public IdentityClientOptions()
{
IdentityClients = new IdentityClientConfigurationDictionary();
}
}
}

27
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpClientAuthenticateContext.cs

@ -0,0 +1,27 @@
using System.Net.Http;
namespace Volo.Abp.IdentityModel
{
public class IdentityModelHttpClientAuthenticateContext
{
public HttpClient Client { get; }
/// <summary>
/// The identity client name configured with the <see cref="IdentityClientOptions"/>.
/// </summary>
public string IdentityClientName { get; }
/// <summary>
///
/// </summary>
/// <param name="client"><see cref="HttpClient"/> object to be authorized</param>
/// <param name="identityClientName">The identity client name configured with the <see cref="IdentityClientOptions"/>.</param>
public IdentityModelHttpClientAuthenticateContext(
HttpClient client,
string identityClientName = null)
{
Client = client;
IdentityClientName = identityClientName;
}
}
}

96
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using IdentityModel;
using IdentityModel.Client;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.IdentityModel
{
[Dependency(ReplaceServices = true)]
public class IdentityModelHttpClientAuthenticator : IIdentityModelHttpClientAuthenticator, ITransientDependency
{
protected IdentityClientOptions ClientOptions { get; }
public IdentityModelHttpClientAuthenticator(
IOptions<IdentityClientOptions> options)
{
ClientOptions = options.Value;
}
public async Task Authenticate(IdentityModelHttpClientAuthenticateContext context)
{
var accessToken = await GetAccessTokenFromServerOrNullAsync(context);
if (accessToken != null)
{
//TODO: "Bearer" should be configurable
context.Client.DefaultRequestHeaders.Authorization
= new AuthenticationHeaderValue("Bearer", accessToken);
}
}
protected virtual async Task<string> GetAccessTokenFromServerOrNullAsync(IdentityModelHttpClientAuthenticateContext context)
{
var configuration = GetClientConfiguration(context);
if (configuration == null)
{
return null;
}
var discoveryResponse = await GetDiscoveryResponse(configuration);
if (discoveryResponse.IsError)
{
return null;
}
var tokenResponse = await GetTokenResponse(discoveryResponse, configuration);
if (tokenResponse.IsError)
{
return null;
}
return tokenResponse.AccessToken;
}
private IdentityClientConfiguration GetClientConfiguration(IdentityModelHttpClientAuthenticateContext context)
{
if (context.IdentityClientName.IsNullOrEmpty())
{
return ClientOptions.IdentityClients.Default;
}
return ClientOptions.IdentityClients.GetOrDefault(context.IdentityClientName) ??
ClientOptions.IdentityClients.Default;
}
protected virtual async Task<DiscoveryResponse> GetDiscoveryResponse(IdentityClientConfiguration configuration)
{
return await DiscoveryClient.GetAsync(configuration.Authority);
}
protected virtual async Task<TokenResponse> GetTokenResponse(DiscoveryResponse discoveryResponse, IdentityClientConfiguration configuration)
{
var tokenClient = new TokenClient(discoveryResponse.TokenEndpoint, configuration.ClientId, configuration.ClientSecret);
switch (configuration.GrantType)
{
case OidcConstants.GrantTypes.ClientCredentials:
return await tokenClient.RequestClientCredentialsAsync(
configuration.Scope
);
case OidcConstants.GrantTypes.Password:
return await tokenClient.RequestResourceOwnerPasswordAsync(
configuration.UserName,
configuration.UserPassword,
configuration.Scope
);
default:
throw new AbpException("Grant type was not implemented: " + configuration.GrantType);
}
}
}
}

6
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -221,7 +221,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
public override async Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().ToListAsync(cancellationToken);
return await GetMongoQueryable().ToListAsync(GetCancellationToken(cancellationToken));
}
public override long GetCount()
@ -231,7 +231,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
public override async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().LongCountAsync(cancellationToken);
return await GetMongoQueryable().LongCountAsync(GetCancellationToken(cancellationToken));
}
public override void Delete(Expression<Func<TEntity, bool>> predicate, bool autoSave = false)
@ -257,7 +257,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
foreach (var entity in entities)
{
await DeleteAsync(entity, autoSave, GetCancellationToken(cancellationToken));
await DeleteAsync(entity, autoSave, cancellationToken);
}
}

26
framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/TenantSettingValueProvider.cs

@ -19,27 +19,27 @@ namespace Volo.Abp.MultiTenancy
public override async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
if (providerKey == null)
{
if (CurrentTenant.Id == null)
{
return null;
}
providerKey = CurrentTenant.Id.ToString();
}
return await SettingStore.GetOrNullAsync(setting.Name, Name, providerKey);
return await SettingStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
public override Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
return SettingStore.SetAsync(setting.Name, value, Name, providerKey);
return SettingStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey));
}
public override Task ClearAsync(SettingDefinition setting, string providerKey)
{
return SettingStore.DeleteAsync(setting.Name, Name, providerKey);
return SettingStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
private string NormalizeProviderKey(string providerKey)
{
if (providerKey == null && CurrentTenant.Id.HasValue)
{
return CurrentTenant.Id.Value.ToString();
}
return providerKey;
}
}
}

7
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs

@ -10,6 +10,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using Volo.Abp.Http;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Json;
using Volo.Abp.TestApp.Application.Dto;
@ -66,7 +67,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var response = await Client.PostAsync(
"/api/app/people",
new StringContent(postData, Encoding.UTF8, "application/json")
new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json)
);
response.StatusCode.ShouldBe(HttpStatusCode.OK);
@ -98,7 +99,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var response = await Client.PutAsync(
$"/api/app/people/{updateDto.Id}",
new StringContent(putData, Encoding.UTF8, "application/json")
new StringContent(putData, Encoding.UTF8, MimeTypes.Application.Json)
);
response.StatusCode.ShouldBe(HttpStatusCode.OK);
@ -131,7 +132,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var response = await Client.PostAsync(
$"/api/app/people/{personToAddNewPhone.Id}/phones",
new StringContent(postData, Encoding.UTF8, "application/json")
new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json)
);
response.StatusCode.ShouldBe(HttpStatusCode.OK);

4
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs

@ -5,7 +5,7 @@ using Volo.Abp.Account.Web.Settings;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.Identity;
using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Localization;
using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity;
@ -15,7 +15,7 @@ using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Account.Web
{
[DependsOn(typeof(AbpIdentityDomainModule))]
[DependsOn(typeof(AbpIdentityAspNetCoreModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))]
public class AbpAccountWebModule : AbpModule
{

2
modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj

@ -30,7 +30,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
</ItemGroup>

2
modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs

@ -76,7 +76,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore
b.Property(x => x.ChangeType).IsRequired().HasColumnName(nameof(EntityChange.ChangeType));
b.Property(x => x.TenantId).HasColumnName(nameof(EntityChange.TenantId));
b.HasMany<EntityPropertyChange>().WithOne().HasForeignKey(x => x.EntityChangeId);
b.HasMany(a => a.PropertyChanges).WithOne().HasForeignKey(x => x.EntityChangeId);
b.HasIndex(x => new { x.AuditLogId });
b.HasIndex(x => new { x.TenantId, x.EntityTypeFullName, x.EntityId });

2
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/Create.cshtml.cs

@ -31,7 +31,7 @@ namespace Volo.Docs.Admin.Pages.Docs.Admin.Projects
public async Task<ActionResult> OnGetAsync(string source)
{
if (source == "GitHub")
if (source != null && source.ToLowerInvariant() == "github")
{
GithubProject = new CreateGithubProjectViewModel();
return Page();

2
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/Index.cshtml

@ -34,7 +34,7 @@
<abp-dropdown>
<abp-dropdown-button button-type="Primary" icon="plus" text="@L["CreateANewProject"].Value" />
<abp-dropdown-menu align="Right">
<abp-dropdown-item href="#" id="CreateNewGithubProjectButtonId">Github</abp-dropdown-item>
<abp-dropdown-item href="#" id="CreateNewGithubProjectButtonId"><i class="fa fa-github"></i> Github</abp-dropdown-item>
</abp-dropdown-menu>
</abp-dropdown>
}

1
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/en.json

@ -7,6 +7,7 @@
"ShareOn": "Share on",
"Version": "Version",
"Edit": "Edit",
"Delete": "Delete",
"InThisDocument": "In this document",
"GoToTop": "Go to top",
"Projects": "Project(s)",

1
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/tr.json

@ -7,6 +7,7 @@
"ShareOn": "Paylaş",
"Version": "Versiyon",
"Edit": "Düzenle",
"Delete": "Sil",
"InThisDocument": "Bu dökümanda",
"GoToTop": "En üste çık",
"Projects": "Proje(ler)",

7
modules/identity/Volo.Abp.Identity.sln

@ -35,6 +35,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Identity.TestBase"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Identity.Domain.Tests", "test\Volo.Abp.Identity.Domain.Tests\Volo.Abp.Identity.Domain.Tests.csproj", "{588B6E38-323B-4251-AC21-5F67C815A44E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Identity.AspNetCore", "src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj", "{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -97,6 +99,10 @@ Global
{588B6E38-323B-4251-AC21-5F67C815A44E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{588B6E38-323B-4251-AC21-5F67C815A44E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{588B6E38-323B-4251-AC21-5F67C815A44E}.Release|Any CPU.Build.0 = Release|Any CPU
{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -116,6 +122,7 @@ Global
{7291DCF0-7AA2-41A6-9AA7-98C2E9D13222} = {9FACAF96-A681-4B36-A938-A37DCA0B7EC1}
{D7F61598-E7CE-4DAB-99EA-C266F0423606} = {9FACAF96-A681-4B36-A938-A37DCA0B7EC1}
{588B6E38-323B-4251-AC21-5F67C815A44E} = {9FACAF96-A681-4B36-A938-A37DCA0B7EC1}
{D5EFC912-75A0-4856-9B8D-DFDD4CD66BAB} = {AADC5A0A-F100-4511-87DE-B74E55F5B69B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {05740D37-83CF-4041-9C2A-D89F1B3DB5A4}

21
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo.Abp.Identity.AspNetCore.csproj

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

38
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs

@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.Identity.AspNetCore
{
[DependsOn(
typeof(AbpIdentityDomainModule)
)]
public class AbpIdentityAspNetCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services
.GetObject<IdentityBuilder>()
.AddDefaultTokenProviders()
.AddSignInManager();
//(TODO: Extract an extension method like IdentityBuilder.AddAbpSecurityStampValidator())
context.Services.AddScoped<AbpSecurityStampValidator>();
context.Services.AddScoped(typeof(SecurityStampValidator<IdentityUser>), provider => provider.GetService(typeof(AbpSecurityStampValidator)));
context.Services.AddScoped(typeof(ISecurityStampValidator), provider => provider.GetService(typeof(AbpSecurityStampValidator)));
var options = context.Services.ExecutePreConfiguredActions(new AbpIdentityAspNetCoreOptions());
if (options.ConfigureAuthentication)
{
context.Services
.AddAuthentication(o =>
{
o.DefaultScheme = IdentityConstants.ApplicationScheme;
o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
}
}
}
}

10
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreOptions.cs

@ -0,0 +1,10 @@
namespace Volo.Abp.Identity.AspNetCore
{
public class AbpIdentityAspNetCoreOptions
{
/// <summary>
/// Default: true.
/// </summary>
public bool ConfigureAuthentication { get; set; } = true;
}
}

0
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpSecurityStampValidator.cs → modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs

6
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityClaimValueType.cs

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volo.Abp.Identity
namespace Volo.Abp.Identity
{
public enum IdentityClaimValueType
{

11
modules/identity/src/Volo.Abp.Identity.Domain/Microsoft/Extensions/DependencyInjection/AbpIdentityServiceCollectionExtensions.cs

@ -22,11 +22,6 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddScoped<IdentityUserManager>();
services.TryAddScoped(typeof(UserManager<IdentityUser>), provider => provider.GetService(typeof(IdentityUserManager)));
//AbpSecurityStampValidator
services.TryAddScoped<AbpSecurityStampValidator>();
services.TryAddScoped(typeof(SecurityStampValidator<IdentityUser>), provider => provider.GetService(typeof(AbpSecurityStampValidator)));
services.TryAddScoped(typeof(ISecurityStampValidator), provider => provider.GetService(typeof(AbpSecurityStampValidator)));
//AbpUserStore
services.TryAddScoped<IdentityUserStore>();
services.TryAddScoped(typeof(IUserStore<IdentityUser>), provider => provider.GetService(typeof(IdentityUserStore)));
@ -35,10 +30,10 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddScoped<IdentityRoleStore>();
services.TryAddScoped(typeof(IRoleStore<IdentityRole>), provider => provider.GetService(typeof(IdentityRoleStore)));
return services.AddIdentity<IdentityUser, IdentityRole>(setupAction)
.AddDefaultTokenProviders()
return services
.AddIdentityCore<IdentityUser>(setupAction)
.AddRoles<IdentityRole>()
.AddClaimsPrincipalFactory<AbpUserClaimsPrincipalFactory>();
//return services.AddIdentityCore<IdentityUser>(setupAction);
}
}
}

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj

@ -27,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="2.2.0" />
</ItemGroup>
</Project>

1
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs

@ -55,6 +55,7 @@ namespace Volo.Abp.Identity
options.User.RequireUniqueEmail = true;
});
context.Services.AddObjectAccessor(identityBuilder);
context.Services.ExecutePreConfiguredActions(identityBuilder);
AddAbpIdentityOptionsFactory(context.Services);

13
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIDentityClaimTypeRepository.cs

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -8,10 +7,16 @@ namespace Volo.Abp.Identity
{
public interface IIdentityClaimTypeRepository : IBasicRepository<IdentityClaimType, Guid>
{
Task<bool> DoesNameExist(string name, Guid? claimTypeId = null);
/// <summary>
/// Checks if there is a <see cref="IdentityClaimType"/> entity with given name.
/// </summary>
/// <param name="name">Name to check</param>
/// <param name="ignoredId">
/// An Id value to ignore on checking.
/// If there is an entity with given <paramref name="ignoredId"/> it's ignored.
/// </param>
Task<bool> AnyAsync(string name, Guid? ignoredId = null);
Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount);
Task<int> GetTotalCount();
}
}

14
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdenityClaimTypeManager.cs

@ -1,26 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
namespace Volo.Abp.Identity
{
public class IdenityClaimTypeManager : DomainService
{
private readonly IIdentityClaimTypeRepository _identityClaimTypeRepository;
private readonly IGuidGenerator _guidGenerator;
public IdenityClaimTypeManager(IIdentityClaimTypeRepository identityClaimTypeRepository, IGuidGenerator guidGenerator)
public IdenityClaimTypeManager(IIdentityClaimTypeRepository identityClaimTypeRepository)
{
_identityClaimTypeRepository = identityClaimTypeRepository;
_guidGenerator = guidGenerator;
}
public virtual async Task<IdentityClaimType> CreateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.DoesNameExist(claimType.Name))
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name))
{
throw new AbpException($"Name Exist: {claimType.Name}");
}
@ -30,7 +24,7 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityClaimType> UpdateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.DoesNameExist(claimType.Name, claimType.Id))
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id))
{
throw new AbpException($"Name Exist: {claimType.Name}");
}

26
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimType.cs

@ -1,5 +1,5 @@
using System;
using JetBrains.Annotations;
using JetBrains.Annotations;
using System;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Identity
@ -8,15 +8,15 @@ namespace Volo.Abp.Identity
{
public virtual string Name { get; protected set; }
public virtual bool Required { get; protected set; }
public virtual bool Required { get; set; }
public virtual bool IsStatic { get; protected set; }
public virtual string Regex { get; protected set; }
public virtual string Regex { get; set; }
public virtual string RegexDescription { get; protected set; }
public virtual string RegexDescription { get; set; }
public virtual string Description { get; protected set; }
public virtual string Description { get; set; }
public virtual IdentityClaimValueType ValueType { get; protected set; }
@ -25,12 +25,18 @@ namespace Volo.Abp.Identity
}
public IdentityClaimType(Guid id, [NotNull] string name, bool required, bool isStatic, [CanBeNull]string regex, [CanBeNull]string regexDescription, [CanBeNull] string description, IdentityClaimValueType valueType = IdentityClaimValueType.String)
public IdentityClaimType(
Guid id,
[NotNull] string name,
bool required = false,
bool isStatic = false,
[CanBeNull] string regex = null,
[CanBeNull] string regexDescription = null,
[CanBeNull] string description = null,
IdentityClaimValueType valueType = IdentityClaimValueType.String)
{
Check.NotNull(name, nameof(name));
Id = id;
Name = name;
Name = Check.NotNull(name, nameof(name));
Required = required;
IsStatic = isStatic;
Regex = regex;

15
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs

@ -11,13 +11,17 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
public class EfCoreIdentityClaimTypeRepository : EfCoreRepository<IIdentityDbContext, IdentityClaimType, Guid>, IIdentityClaimTypeRepository
{
public EfCoreIdentityClaimTypeRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider) : base(dbContextProvider)
public EfCoreIdentityClaimTypeRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async Task<bool> DoesNameExist(string name, Guid? claimTypeId = null)
public async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
{
return await DbSet.WhereIf(claimTypeId != null, ct => ct.Id != claimTypeId).CountAsync(ct => ct.Name == name) > 0;
return await DbSet
.WhereIf(ignoredId != null, ct => ct.Id != ignoredId)
.CountAsync(ct => ct.Name == name) > 0;
}
public async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount)
@ -28,10 +32,5 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return identityClaimTypes;
}
public async Task<int> GetTotalCount()
{
return await DbSet.CountAsync();
}
}
}

35
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using System.Linq;
using System.Linq.Dynamic.Core;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
@ -15,23 +16,29 @@ namespace Volo.Abp.Identity.MongoDB
{
}
public async Task<bool> DoesNameExist(string name, Guid? claimTypeId = null)
public async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
{
return GetMongoQueryable().WhereIf(claimTypeId != null, ct => ct.Id != claimTypeId).Count(ct => ct.Name == name) > 0;
if (ignoredId == null)
{
return await GetMongoQueryable()
.Where(ct => ct.Name == name)
.AnyAsync();
}
else
{
return await GetMongoQueryable()
.Where(ct => ct.Id != ignoredId && ct.Name == name)
.AnyAsync();
}
}
public async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount)
{
var identityClaimTypes = GetMongoQueryable().OrderBy(sorting ?? "name desc")
.PageBy(skipCount, maxResultCount)
.ToList();
return identityClaimTypes;
}
public async Task<int> GetTotalCount()
{
return await GetMongoQueryable().CountAsync();
return await GetMongoQueryable()
.OrderBy(sorting ?? nameof(IdentityClaimType.Name))
.As<IMongoQueryable<IdentityClaimType>>()
.PageBy<IdentityClaimType, IMongoQueryable<IdentityClaimType>>(skipCount, maxResultCount)
.ToListAsync();
}
}
}

5
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/ProfileAppService_Tests.cs

@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
@ -12,16 +11,12 @@ namespace Volo.Abp.Identity
public class ProfileAppService_Tests : AbpIdentityApplicationTestBase
{
private readonly IProfileAppService _profileAppService;
private readonly IIdentityUserRepository _userRepository;
private readonly SignInManager<IdentityUser> _signInManager;
private readonly IdentityTestData _testData;
private ICurrentUser _currentUser;
public ProfileAppService_Tests()
{
_profileAppService = GetRequiredService<IProfileAppService>();
_userRepository = GetRequiredService<IIdentityUserRepository>();
_signInManager = GetRequiredService<SignInManager<IdentityUser>>();
_testData = GetRequiredService<IdentityTestData>();
}

4
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityClaimTypeRepository_Tests.cs

@ -28,11 +28,11 @@ namespace Volo.Abp.Identity
{
var claim = (await ClaimTypeRepository.GetListAsync()).FirstOrDefault();
var result1 = await ClaimTypeRepository.DoesNameExist(claim.Name);
var result1 = await ClaimTypeRepository.AnyAsync(claim.Name);
result1.ShouldBe(true);
var result2 = await ClaimTypeRepository.DoesNameExist(Guid.NewGuid().ToString());
var result2 = await ClaimTypeRepository.AnyAsync(Guid.NewGuid().ToString());
result2.ShouldBe(false);
}

40
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using IdentityServer4;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
@ -57,16 +58,27 @@ namespace Volo.Abp.IdentityServer.ApiResources
Secrets.Add(new ApiSecret(Id, value, expiration, type, description));
}
public virtual void AddScope(
public virtual void RemoveSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
Secrets.RemoveAll(s => s.Value == value && s.Type == type);
}
public virtual ApiSecret FindSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return Secrets.FirstOrDefault(s => s.Type == type && s.Value == value);
}
public virtual ApiScope AddScope(
[NotNull] string name,
string displayName = null,
string description = null,
bool required = false,
bool emphasize = false,
bool showInDiscoveryDocument = true,
ApiScopeClaim[] userClaims = null)
bool showInDiscoveryDocument = true)
{
Scopes.Add(new ApiScope(Id, name, displayName, description, required, emphasize, showInDiscoveryDocument));
var scope = new ApiScope(Id, name, displayName, description, required, emphasize, showInDiscoveryDocument);
Scopes.Add(scope);
return scope;
}
public virtual void AddUserClaim([NotNull] string type)
@ -79,6 +91,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
UserClaims.Clear();
}
public virtual void RemoveClaim(string type)
{
UserClaims.RemoveAll(c => c.Type == type);
}
public virtual ApiResourceClaim FindClaim(string type)
{
return UserClaims.FirstOrDefault(c => c.Type == type);
}
public virtual void RemoveAllSecrets()
{
Secrets.Clear();
@ -92,5 +114,15 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
Scopes.Clear();
}
public virtual void RemoveScope(string name)
{
Scopes.RemoveAll(r => r.Name == name);
}
public virtual ApiScope FindScope(string name)
{
return Scopes.FirstOrDefault(r => r.Name == name);
}
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResourceClaim.cs

@ -9,7 +9,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiResourceClaim()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string type)
{
return ApiResourceId == apiResourceId && Type == type;
}
protected internal ApiResourceClaim(Guid apiResourceId, [NotNull] string type)

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

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
@ -26,7 +27,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiScope()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string name)
{
return ApiResourceId == apiResourceId && Name == name;
}
protected internal ApiScope(
@ -61,6 +67,16 @@ namespace Volo.Abp.IdentityServer.ApiResources
UserClaims.Clear();
}
public virtual void RemoveClaim(string name, string type)
{
UserClaims.RemoveAll(r => r.Name == name && r.Type == type);
}
public virtual ApiScopeClaim FindClaim(string name, string type)
{
return UserClaims.FirstOrDefault(r => r.Name == name && r.Type == type);
}
public override object[] GetKeys()
{
return new object[] { ApiResourceId, Name };

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiScopeClaim.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string name, [NotNull] string type)
{
return ApiResourceId == apiResourceId && Name == name && Type == type;
}
protected internal ApiScopeClaim(Guid apiResourceId, [NotNull] string name, [NotNull] string type)
: base(type)
{

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiSecret.cs

@ -10,7 +10,12 @@ namespace Volo.Abp.IdentityServer.ApiResources
protected ApiSecret()
{
}
public virtual bool Equals(Guid apiResourceId, [NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return ApiResourceId == apiResourceId && Value == value && Type == type;
}
protected internal ApiSecret(

110
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs

@ -144,18 +144,19 @@ namespace Volo.Abp.IdentityServer.Clients
AllowedGrantTypes.Add(new ClientGrantType(Id, grantType));
}
public virtual void AddGrantTypes(IEnumerable<string> grantTypes)
public virtual void RemoveAllAllowedGrantTypes()
{
AllowedGrantTypes.AddRange(
grantTypes.Select(
grantType => new ClientGrantType(Id, grantType)
)
);
AllowedGrantTypes.Clear();
}
public virtual void RemoveAllAllowedGrantTypes()
public virtual void RemoveGrantType(string grantType)
{
AllowedGrantTypes.Clear();
AllowedGrantTypes.RemoveAll(r => r.GrantType == grantType);
}
public virtual ClientGrantType FindGrantType(string grantType)
{
return AllowedGrantTypes.FirstOrDefault(r => r.GrantType == grantType);
}
public virtual void AddSecret([NotNull] string value, DateTime? expiration = null, string type = IdentityServerConstants.SecretTypes.SharedSecret, string description = null)
@ -168,11 +169,6 @@ namespace Volo.Abp.IdentityServer.Clients
ClientSecrets.RemoveAll(s => s.Value == value && s.Type == type);
}
public virtual void RemoveAllSecrets()
{
ClientSecrets.Clear();
}
public virtual ClientSecret FindSecret([NotNull] string value, string type = IdentityServerConstants.SecretTypes.SharedSecret)
{
return ClientSecrets.FirstOrDefault(s => s.Type == type && s.Value == value);
@ -188,6 +184,16 @@ namespace Volo.Abp.IdentityServer.Clients
AllowedScopes.Clear();
}
public virtual void RemoveScope(string scope)
{
AllowedScopes.RemoveAll(r => r.Scope == scope);
}
public virtual ClientScope FindScope(string scope)
{
return AllowedScopes.FirstOrDefault(r => r.Scope == scope);
}
public virtual void AddCorsOrigin([NotNull] string origin)
{
AllowedCorsOrigins.Add(new ClientCorsOrigin(Id, origin));
@ -203,29 +209,49 @@ namespace Volo.Abp.IdentityServer.Clients
PostLogoutRedirectUris.Add(new ClientPostLogoutRedirectUri(Id, postLogoutRedirectUri));
}
public virtual void RemoveAllCorsOrigin()
public virtual void RemoveAllCorsOrigins()
{
AllowedCorsOrigins.Clear();
}
public virtual void RemoveAllRedirectUri()
public virtual void RemoveCorsOrigin(string uri)
{
AllowedCorsOrigins.RemoveAll(c => c.Origin == uri);
}
public virtual void RemoveAllRedirectUris()
{
RedirectUris.Clear();
}
public virtual void RemoveAllPostLogoutRedirectUri()
public virtual void RemoveRedirectUri(string uri)
{
RedirectUris.RemoveAll(r => r.RedirectUri == uri);
}
public virtual void RemoveAllPostLogoutRedirectUris()
{
PostLogoutRedirectUris.Clear();
}
public virtual void AddIdentityProviderRestriction([NotNull] string provider)
public virtual void RemovePostLogoutRedirectUri(string uri)
{
IdentityProviderRestrictions.Add(new ClientIdPRestriction(Id, provider));
PostLogoutRedirectUris.RemoveAll(p => p.PostLogoutRedirectUri == uri);
}
public virtual void RemoveAllIdentityProviderRestriction()
public virtual ClientCorsOrigin FindCorsOrigin(string uri)
{
IdentityProviderRestrictions.Clear();
return AllowedCorsOrigins.FirstOrDefault(c => c.Origin == uri);
}
public virtual ClientRedirectUri FindRedirectUri(string uri)
{
return RedirectUris.FirstOrDefault(r => r.RedirectUri == uri);
}
public virtual ClientPostLogoutRedirectUri FindPostLogoutRedirectUri(string uri)
{
return PostLogoutRedirectUris.FirstOrDefault(p => p.PostLogoutRedirectUri == uri);
}
public virtual void AddProperty([NotNull] string key, [NotNull] string value)
@ -238,14 +264,54 @@ namespace Volo.Abp.IdentityServer.Clients
Properties.Clear();
}
public virtual void AddClaim(IGuidGenerator guidGenerator, [NotNull] string type, string value)
public virtual void RemoveProperty(string key, string value)
{
Properties.RemoveAll(c => c.Value == value && c.Key == key);
}
public virtual ClientProperty FindProperty(string key, string value)
{
return Properties.FirstOrDefault(c => c.Key == key && c.Value == value);
}
public virtual void AddClaim([NotNull] string value, string type)
{
Claims.Add(new ClientClaim(guidGenerator.Create(), Id, type, value));
Claims.Add(new ClientClaim(Id, type, value));
}
public virtual void RemoveAllClaims()
{
Claims.Clear();
}
public virtual void RemoveClaim(string value, string type)
{
Claims.RemoveAll(c => c.Value == value && c.Type == type);
}
public virtual ClientClaim FindClaim(string value, string type)
{
return Claims.FirstOrDefault(c => c.Type == type && c.Value == value);
}
public virtual void AddIdentityProviderRestriction([NotNull] string provider)
{
IdentityProviderRestrictions.Add(new ClientIdPRestriction(Id, provider));
}
public virtual void RemoveAllIdentityProviderRestrictions()
{
IdentityProviderRestrictions.Clear();
}
public virtual void RemoveIdentityProviderRestriction(string provider)
{
IdentityProviderRestrictions.RemoveAll(r => r.Provider == provider);
}
public virtual ClientIdPRestriction FindIdentityProviderRestriction(string provider)
{
return IdentityProviderRestrictions.FirstOrDefault(r => r.Provider == provider);
}
}
}

17
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientClaim.cs

@ -4,7 +4,7 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Clients
{
public class ClientClaim : Entity<Guid>
public class ClientClaim : Entity
{
public virtual Guid ClientId { get; set; }
@ -14,17 +14,26 @@ namespace Volo.Abp.IdentityServer.Clients
protected ClientClaim()
{
}
public virtual bool Equals(Guid clientId, string value, string type)
{
return ClientId == clientId && Type == type && Value == value;
}
protected internal ClientClaim(Guid id, Guid clientId, [NotNull] string type, string value)
protected internal ClientClaim(Guid clientId, [NotNull] string type, string value)
{
Check.NotNull(type, nameof(type));
Id = id;
ClientId = clientId;
Type = type;
Value = value;
}
public override object[] GetKeys()
{
return new object[] { ClientId, Type, Value };
}
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientCorsOrigin.cs

@ -12,7 +12,12 @@ namespace Volo.Abp.IdentityServer.Clients
protected ClientCorsOrigin()
{
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && Origin == uri;
}
protected internal ClientCorsOrigin(Guid clientId, [NotNull] string origin)

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientGrantType.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string grantType)
{
return ClientId == clientId && GrantType == grantType;
}
protected internal ClientGrantType(Guid clientId, [NotNull] string grantType)
{
Check.NotNull(grantType, nameof(grantType));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientIdPRestriction.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string provider)
{
return ClientId == clientId && Provider == provider;
}
protected internal ClientIdPRestriction(Guid clientId, [NotNull] string provider)
{
Check.NotNull(provider, nameof(provider));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUri.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && PostLogoutRedirectUri == uri;
}
protected internal ClientPostLogoutRedirectUri(Guid clientId, [NotNull] string postLogoutRedirectUri)
{
Check.NotNull(postLogoutRedirectUri, nameof(postLogoutRedirectUri));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientProperty.cs

@ -17,6 +17,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string key, string value)
{
return ClientId == clientId && Key == key && Value == value;
}
protected internal ClientProperty(Guid clientId, [NotNull] string key, [NotNull] string value)
{
Check.NotNull(key, nameof(key));

5
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientRedirectUri.cs

@ -15,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string uri)
{
return ClientId == clientId && RedirectUri == uri;
}
protected internal ClientRedirectUri(Guid clientId, [NotNull] string redirectUri)
{
Check.NotNull(redirectUri, nameof(redirectUri));

6
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/ClientScope.cs

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.IdentityServer.Clients
@ -14,6 +15,11 @@ namespace Volo.Abp.IdentityServer.Clients
}
public virtual bool Equals(Guid clientId, [NotNull] string scope)
{
return ClientId == clientId && Scope == scope;
}
protected internal ClientScope(Guid clientId, string scope)
{
ClientId = clientId;

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

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Volo.Abp.IdentityServer.IdentityResources
{
public interface IIdentityResourceDataSeeder
{
Task CreateStandardResourcesAsync();
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IIdentityResourceRepository.cs

@ -22,11 +22,12 @@ namespace Volo.Abp.IdentityServer.IdentityResources
CancellationToken cancellationToken = default
);
Task<List<IdentityResource>> GetListAsync(
bool includeDetails = false,
Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,
CancellationToken cancellationToken = default
);
Task<long> GetTotalCount();
Task<long> GetTotalCountAsync();
}
}

7
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityClaim.cs

@ -9,7 +9,12 @@ namespace Volo.Abp.IdentityServer.IdentityResources
protected IdentityClaim()
{
}
public virtual bool Equals(Guid identityResourceId, [NotNull] string type)
{
return IdentityResourceId == identityResourceId && Type == type;
}
protected internal IdentityClaim(Guid identityResourceId, [NotNull] string type)

24
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
@ -52,6 +53,19 @@ namespace Volo.Abp.IdentityServer.IdentityResources
UserClaims = new List<IdentityClaim>();
}
public IdentityResource(Guid id, IdentityServer4.Models.IdentityResource resource)
{
Id = id;
Name = resource.Name;
DisplayName = resource.DisplayName;
Description = resource.Description;
Enabled = resource.Enabled;
Required = resource.Required;
Emphasize = resource.Emphasize;
ShowInDiscoveryDocument = resource.ShowInDiscoveryDocument;
UserClaims = resource.UserClaims.Select(claimType => new IdentityClaim(id, claimType)).ToList();
}
public virtual void AddUserClaim([NotNull] string type)
{
UserClaims.Add(new IdentityClaim(Id, type));
@ -61,5 +75,15 @@ namespace Volo.Abp.IdentityServer.IdentityResources
{
UserClaims.Clear();
}
public virtual void RemoveUserClaim(string type)
{
UserClaims.RemoveAll(c => c.Type == type);
}
public virtual IdentityClaim FindUserClaim(string type)
{
return UserClaims.FirstOrDefault(c => c.Type == type);
}
}
}

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

@ -0,0 +1,77 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
namespace Volo.Abp.IdentityServer.IdentityResources
{
public class IdentityResourceDataSeeder : IIdentityResourceDataSeeder, ITransientDependency
{
protected IIdentityClaimTypeRepository ClaimTypeRepository { get; }
protected IIdentityResourceRepository IdentityResourceRepository { get; }
protected IGuidGenerator GuidGenerator { get; }
public IdentityResourceDataSeeder(
IIdentityResourceRepository identityResourceRepository,
IGuidGenerator guidGenerator,
IIdentityClaimTypeRepository claimTypeRepository)
{
IdentityResourceRepository = identityResourceRepository;
GuidGenerator = guidGenerator;
ClaimTypeRepository = claimTypeRepository;
}
public virtual async Task CreateStandardResourcesAsync()
{
var resources = new IdentityServer4.Models.IdentityResource[]
{
new IdentityServer4.Models.IdentityResources.OpenId(),
new IdentityServer4.Models.IdentityResources.Profile(),
new IdentityServer4.Models.IdentityResources.Email(),
new IdentityServer4.Models.IdentityResources.Address(),
new IdentityServer4.Models.IdentityResources.Phone()
};
foreach (var resource in resources)
{
foreach (var claimType in resource.UserClaims)
{
await AddClaimTypeIfNotExistsAsync(claimType);
}
await AddIdentityResourceIfNotExistsAsync(resource);
}
}
protected virtual async Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource)
{
if (await IdentityResourceRepository.FindByNameAsync(resource.Name) != null)
{
return;
}
await IdentityResourceRepository.InsertAsync(
new IdentityResource(
GuidGenerator.Create(),
resource
)
);
}
protected virtual async Task AddClaimTypeIfNotExistsAsync(string claimType)
{
if (await ClaimTypeRepository.AnyAsync(claimType))
{
return;
}
await ClaimTypeRepository.InsertAsync(
new IdentityClaimType(
GuidGenerator.Create(),
claimType,
isStatic: true
)
);
}
}
}

26
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiResources/ApiResourceRepository.cs

@ -66,32 +66,6 @@ namespace Volo.Abp.IdentityServer.ApiResources
return await DbSet.CountAsync();
}
public override async Task<ApiResource> UpdateAsync(ApiResource entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiResourceId == entity.Id);
foreach (var scopeClaim in scopeClaims)
{
DbContext.Set<ApiScopeClaim>().Remove(scopeClaim);
}
var scopes = DbContext.Set<ApiScope>().Where(s => s.ApiResourceId == entity.Id);
foreach (var scope in scopes)
{
DbContext.Set<ApiScope>().Remove(scope);
}
var secrets = DbContext.Set<ApiSecret>().Where(s => s.ApiResourceId == entity.Id);
foreach (var secret in secrets)
{
DbContext.Set<ApiSecret>().Remove(secret);
}
return await base.UpdateAsync(entity, autoSave, cancellationToken);
}
public override async Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = default)
{
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiResourceId == id);

69
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs

@ -42,75 +42,6 @@ namespace Volo.Abp.IdentityServer.Clients
return await DbSet.CountAsync();
}
//public override async Task<Client> UpdateAsync(Client entity, bool autoSave = false, CancellationToken cancellationToken = default)
//{
// var secrets = DbContext.Set<ClientSecret>().Where(s => s.ClientId == entity.Id);
// foreach (var secret in secrets)
// {
// DbContext.Set<ClientSecret>().Remove(secret);
// }
// var claims = DbContext.Set<ClientClaim>().Where(s => s.ClientId == entity.Id);
// foreach (var claim in claims)
// {
// DbContext.Set<ClientClaim>().Remove(claim);
// }
// var grantTypes = DbContext.Set<ClientGrantType>().Where(s => s.ClientId == entity.Id);
// foreach (var grantType in grantTypes)
// {
// DbContext.Set<ClientGrantType>().Remove(grantType);
// }
// var restrictions = DbContext.Set<ClientIdPRestriction>().Where(s => s.ClientId == entity.Id);
// foreach (var restriction in restrictions)
// {
// DbContext.Set<ClientIdPRestriction>().Remove(restriction);
// }
// var properties = DbContext.Set<ClientProperty>().Where(s => s.ClientId == entity.Id);
// foreach (var clientProperty in properties)
// {
// DbContext.Set<ClientProperty>().Remove(clientProperty);
// }
// var scopes = DbContext.Set<ClientScope>().Where(s => s.ClientId == entity.Id);
// foreach (var scope in scopes)
// {
// DbContext.Set<ClientScope>().Remove(scope);
// }
// var corsOrigins = DbContext.Set<ClientCorsOrigin>().Where(s => s.ClientId == entity.Id);
// foreach (var corsOrigin in corsOrigins)
// {
// DbContext.Set<ClientCorsOrigin>().Remove(corsOrigin);
// }
// var redirectUris = DbContext.Set<ClientRedirectUri>().Where(s => s.ClientId == entity.Id);
// foreach (var redirectUri in redirectUris)
// {
// DbContext.Set<ClientRedirectUri>().Remove(redirectUri);
// }
// var postLogoutRedirectUris = DbContext.Set<ClientPostLogoutRedirectUri>().Where(s => s.ClientId == entity.Id);
// foreach (var postLogoutRedirectUri in postLogoutRedirectUris)
// {
// DbContext.Set<ClientPostLogoutRedirectUri>().Remove(postLogoutRedirectUri);
// }
// return await base.UpdateAsync(entity, autoSave, cancellationToken);
//}
public override IQueryable<Client> WithDetails()
{
return GetQueryable().IncludeDetails();

2
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs

@ -103,6 +103,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
{
claim.ToTable(tablePrefix + "ClientClaims", schema);
claim.HasKey(x => new { x.ClientId, x.Type, x.Value });
claim.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired();
claim.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired();
});

25
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceRepository.cs

@ -31,15 +31,6 @@ namespace Volo.Abp.IdentityServer.IdentityResources
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityResource>> GetListAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public override IQueryable<IdentityResource> WithDetails()
{
return GetQueryable().IncludeDetails();
@ -49,12 +40,24 @@ namespace Volo.Abp.IdentityServer.IdentityResources
bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails).OrderBy(sorting ?? "name desc")
.IncludeDetails(includeDetails)
.OrderBy(sorting ?? "name desc")
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalCount()
public async Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await DbSet
.IncludeDetails(includeDetails)
.Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalCountAsync()
{
return await DbSet.CountAsync();
}

12
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

@ -28,6 +28,16 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<IdentityResource> FindByNameAsync(
string name,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(x => x.Name == name)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityResource>> GetListByScopesAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -36,7 +46,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetTotalCount()
public virtual async Task<long> GetTotalCountAsync()
{
return await GetCountAsync();
}

14
modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.IdentityServer
{
public class AbpIdentityServerTestData : ISingletonDependency
{
public Guid Client1Id { get; } = Guid.NewGuid();
public Guid ApiResource1Id { get; } = Guid.NewGuid();
public Guid IdentityResource1Id { get; } = Guid.NewGuid();
}
}

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

@ -1,4 +1,5 @@
using Volo.Abp.DependencyInjection;
using System.Collections.Generic;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
@ -14,14 +15,17 @@ namespace Volo.Abp.IdentityServer
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceRepository _identityResourceRepository;
//private readonly IPersistentGrantRepository _persistentGrantRepository;
private readonly AbpIdentityServerTestData _testData;
public AbpIdentityServerTestDataBuilder(
IGuidGenerator guidGenerator,
IApiResourceRepository apiResourceRepository,
IClientRepository clientRepository,
IIdentityResourceRepository identityResourceRepository
IIdentityResourceRepository identityResourceRepository,
AbpIdentityServerTestData testData
/*IPersistentGrantRepository persistentGrantRepository*/)
{
_testData = testData;
_guidGenerator = guidGenerator;
_apiResourceRepository = apiResourceRepository;
_clientRepository = clientRepository;
@ -46,21 +50,42 @@ namespace Volo.Abp.IdentityServer
private void AddIdentityResources()
{
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource1"));
_identityResourceRepository.Insert(new IdentityResource(_testData.IdentityResource1Id, "NewIdentityResource1"));
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource2"));
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create(), "NewIdentityResource3"));
}
private void AddApiResources()
{
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource1"));
_apiResourceRepository.Insert(new ApiResource(_testData.ApiResource1Id, "NewApiResource1"));
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource2"));
_apiResourceRepository.Insert(new ApiResource(_guidGenerator.Create(), "NewApiResource3"));
}
private void AddClients()
{
_clientRepository.Insert(new Client(_guidGenerator.Create(), "ClientId1"));
var client = new Client(_testData.Client1Id, "ClientId1")
{
Description = nameof(Client.Description),
ClientName = nameof(Client.ClientName),
ClientUri = nameof(Client.ClientUri),
LogoUri = nameof(Client.LogoUri),
ProtocolType = nameof(Client.ProtocolType),
FrontChannelLogoutUri = nameof(Client.FrontChannelLogoutUri)
};
client.AddCorsOrigin(nameof(ClientCorsOrigin.Origin));
client.AddClaim(nameof(ClientClaim.Value), nameof(ClientClaim.Type));
client.AddGrantType(nameof(ClientGrantType.GrantType));
client.AddIdentityProviderRestriction(nameof(ClientIdPRestriction.Provider));
client.AddPostLogoutRedirectUri(nameof(ClientPostLogoutRedirectUri.PostLogoutRedirectUri));
client.AddProperty(nameof(ClientProperty.Key), nameof(ClientProperty.Value));
client.AddRedirectUri(nameof(ClientRedirectUri.RedirectUri));
client.AddScope(nameof(ClientScope.Scope));
client.AddSecret(nameof(ClientSecret.Value));
_clientRepository.Insert(client);
_clientRepository.Insert(new Client(_guidGenerator.Create(), "ClientId2"));
_clientRepository.Insert(new Client(_guidGenerator.Create(), "ClientId3"));
}

26
modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserSettingValueProvider.cs

@ -22,27 +22,27 @@ namespace Volo.Abp.Users
public override async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey)
{
if (providerKey == null)
{
if (CurrentUser.Id == null)
{
return null;
}
providerKey = CurrentUser.Id.ToString();
}
return await SettingStore.GetOrNullAsync(setting.Name, Name, providerKey);
return await SettingStore.GetOrNullAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
public override Task SetAsync(SettingDefinition setting, string value, string providerKey)
{
return SettingStore.SetAsync(setting.Name, value, Name, providerKey);
return SettingStore.SetAsync(setting.Name, value, Name, NormalizeProviderKey(providerKey));
}
public override Task ClearAsync(SettingDefinition setting, string providerKey)
{
return SettingStore.DeleteAsync(setting.Name, Name, providerKey);
return SettingStore.DeleteAsync(setting.Name, Name, NormalizeProviderKey(providerKey));
}
private string NormalizeProviderKey(string providerKey)
{
if (providerKey == null && CurrentUser.Id.HasValue)
{
return CurrentUser.Id.Value.ToString();
}
return providerKey;
}
}
}

5
nupkg/common.ps1

@ -62,7 +62,9 @@ $projects = (
"framework/src/Volo.Abp.HangFire",
"framework/src/Volo.Abp.Http",
"framework/src/Volo.Abp.Http.Abstractions",
"framework/src/Volo.Abp.Http.Client",
"framework/src/Volo.Abp.Http.Client",
"framework/src/Volo.Abp.Http.Client.IdentityModel",
"framework/src/Volo.Abp.IdentityModel",
"framework/src/Volo.Abp.Json",
"framework/src/Volo.Abp.Localization",
"framework/src/Volo.Abp.Localization.Abstractions",
@ -119,6 +121,7 @@ $projects = (
"modules/tenant-management/src/Volo.Abp.TenantManagement.Web",
# modules/identity
"modules/identity/src/Volo.Abp.Identity.AspNetCore",
"modules/identity/src/Volo.Abp.Identity.Application",
"modules/identity/src/Volo.Abp.Identity.Application.Contracts",
"modules/identity/src/Volo.Abp.Identity.Domain",

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

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

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

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

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

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

4
samples/BookStore/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreDbContext.cs

@ -21,10 +21,6 @@ namespace Acme.BookStore.EntityFrameworkCore
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Book>(
b => b.ConfigureExtraProperties()
);
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();

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

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

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

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

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

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

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" />
<ProjectReference Include="..\Acme.BookStore.Application.Tests\Acme.BookStore.Application.Tests.csproj" />
<ProjectReference Include="..\..\src\Acme.BookStore.Web\Acme.BookStore.Web.csproj" />
<PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.10.0" />
<PackageReference Include="Volo.Abp.AspNetCore.TestBase" Version="0.11.0" />
</ItemGroup>
<ItemGroup>

31
templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181218134206_Initial.Designer.cs → templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.Designer.cs

@ -10,14 +10,14 @@ using MyCompanyName.MyProjectName.DemoApp;
namespace MyCompanyName.MyProjectName.DemoApp.Migrations
{
[DbContext(typeof(DemoAppDbContext))]
[Migration("20181218134206_Initial")]
[Migration("20190107113413_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@ -134,17 +134,19 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
.HasColumnName("ConcurrencyStamp");
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")
.HasColumnName("Email")
@ -158,11 +160,16 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
b.Property<string>("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")
.ValueGeneratedOnAdd()

12
templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20181218134206_Initial.cs → templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.cs

@ -82,12 +82,12 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 256, nullable: false),
ConcurrencyStamp = table.Column<string>(nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
@ -158,9 +158,9 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
name: "AbpUserLogins",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(nullable: true),
ProviderKey = table.Column<string>(maxLength: 196, nullable: false),
ProviderDisplayName = table.Column<string>(maxLength: 128, nullable: true)
},
@ -179,9 +179,9 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
name: "AbpUserRoles",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
RoleId = table.Column<Guid>(nullable: false)
RoleId = table.Column<Guid>(nullable: false),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
@ -204,10 +204,10 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
name: "AbpUserTokens",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 64, nullable: false),
Name = table.Column<string>(maxLength: 128, nullable: false),
TenantId = table.Column<Guid>(nullable: true),
Value = table.Column<string>(nullable: true)
},
constraints: table =>

29
templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/DemoAppDbContextModelSnapshot.cs

@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@ -132,17 +132,19 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
.HasColumnName("ConcurrencyStamp");
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")
.HasColumnName("Email")
@ -156,11 +158,16 @@ namespace MyCompanyName.MyProjectName.DemoApp.Migrations
b.Property<string>("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")
.ValueGeneratedOnAdd()

2
templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj

@ -34,7 +34,7 @@
</ItemGroup>
<ItemGroup>
<Compile Remove="Migrations\20181212114934_Initial.cs" />
<Compile Remove="Migrations\20181218134206_Initial.cs" />
</ItemGroup>
</Project>

32
templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181218134025_Initial.Designer.cs → templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.Designer.cs

@ -6,19 +6,18 @@ using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using MyCompanyName.MyProjectName.EntityFrameworkCore;
using Volo.Abp.BackgroundJobs;
namespace MyCompanyName.MyProjectName.Migrations
{
[DbContext(typeof(MyProjectNameDbContext))]
[Migration("20181218134025_Initial")]
[Migration("20190107113038_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@ -367,17 +366,19 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasColumnName("ConcurrencyStamp")
.HasMaxLength(256);
.HasColumnName("ConcurrencyStamp");
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")
.HasColumnName("Email")
@ -391,11 +392,16 @@ namespace MyCompanyName.MyProjectName.Migrations
b.Property<string>("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")
.ValueGeneratedOnAdd()

12
templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20181218134025_Initial.cs → templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190107113038_Initial.cs

@ -131,12 +131,12 @@ namespace MyCompanyName.MyProjectName.Migrations
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 256, nullable: false),
ConcurrencyStamp = table.Column<string>(nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
@ -256,9 +256,9 @@ namespace MyCompanyName.MyProjectName.Migrations
name: "AbpUserLogins",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(nullable: true),
ProviderKey = table.Column<string>(maxLength: 196, nullable: false),
ProviderDisplayName = table.Column<string>(maxLength: 128, nullable: true)
},
@ -277,9 +277,9 @@ namespace MyCompanyName.MyProjectName.Migrations
name: "AbpUserRoles",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
RoleId = table.Column<Guid>(nullable: false)
RoleId = table.Column<Guid>(nullable: false),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
@ -302,10 +302,10 @@ namespace MyCompanyName.MyProjectName.Migrations
name: "AbpUserTokens",
columns: table => new
{
TenantId = table.Column<Guid>(nullable: true),
UserId = table.Column<Guid>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 64, nullable: false),
Name = table.Column<string>(maxLength: 128, nullable: false),
TenantId = table.Column<Guid>(nullable: true),
Value = table.Column<string>(nullable: true)
},
constraints: table =>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save