diff --git a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/HomePageLayout.cshtml b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/HomePageLayout.cshtml index c0b7a79b7c..a4c25f8a7b 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/HomePageLayout.cshtml +++ b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/HomePageLayout.cshtml @@ -17,7 +17,7 @@ @(ViewBag.Title == null ? "abp.io" : ViewBag.Title) @await Component.InvokeAsync(typeof(StandardMetaViewComponent)) - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -47,7 +47,7 @@ gtag('config', 'UA-49982725-4'); - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/Layout.cshtml b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/Layout.cshtml index 4fb93a6955..064008d0d6 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/Layout.cshtml +++ b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/Layout.cshtml @@ -17,7 +17,7 @@ @(ViewBag.Title == null ? "abp.io" : ViewBag.Title) @await Component.InvokeAsync(typeof(StandardMetaViewComponent)) - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -58,7 +58,7 @@ gtag('config', 'UA-49982725-4'); - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/LayoutEmpty.cshtml b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/LayoutEmpty.cshtml index 99ee20dacf..f3769b34aa 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/LayoutEmpty.cshtml +++ b/abp_io/src/Volo.AbpWebSite.Web/Pages/Shared/LayoutEmpty.cshtml @@ -18,7 +18,7 @@ @(ViewBag.Title == null ? "abp.io" : ViewBag.Title) @await Component.InvokeAsync(typeof(StandardMetaViewComponent)) - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -41,7 +41,7 @@ gtag('config', 'UA-49982725-4'); - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml index 1a305434db..43c05559f9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml @@ -33,7 +33,7 @@ - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -71,7 +71,7 @@ - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml index 30abd06404..4864f2dafe 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml @@ -23,7 +23,7 @@ - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -39,7 +39,7 @@ - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml index c218f2a918..3b519fd223 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Empty.cshtml @@ -22,7 +22,7 @@ - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -36,7 +36,7 @@ - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs index dbc0fc147a..84dfc91053 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using System.Security.Principal; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; using Volo.Abp.Security.Claims; namespace Volo.Abp.Authorization.Permissions @@ -18,6 +20,8 @@ namespace Volo.Abp.Authorization.Permissions protected ICurrentPrincipalAccessor PrincipalAccessor { get; } + protected ICurrentTenant CurrentTenant { get; } + protected PermissionOptions Options { get; } private readonly Lazy> _lazyProviders; @@ -26,10 +30,12 @@ namespace Volo.Abp.Authorization.Permissions IOptions options, IServiceProvider serviceProvider, ICurrentPrincipalAccessor principalAccessor, - IPermissionDefinitionManager permissionDefinitionManager) + IPermissionDefinitionManager permissionDefinitionManager, + ICurrentTenant currentTenant) { PrincipalAccessor = principalAccessor; PermissionDefinitionManager = permissionDefinitionManager; + CurrentTenant = currentTenant; Options = options.Value; _lazyProviders = new Lazy>( @@ -50,9 +56,17 @@ namespace Volo.Abp.Authorization.Permissions { Check.NotNull(name, nameof(name)); - var isGranted = false; - var permission = PermissionDefinitionManager.Get(name); + + var multiTenancySide = claimsPrincipal?.GetMultiTenancySide() + ?? CurrentTenant.GetMultiTenancySide(); + + if (!permission.MultiTenancySide.HasFlag(multiTenancySide)) + { + return false; + } + + var isGranted = false; var context = new PermissionValueCheckContext(permission, claimsPrincipal); foreach (var provider in ValueProviders) { diff --git a/framework/src/Volo.Abp.Caching/Volo.Abp.Caching.csproj b/framework/src/Volo.Abp.Caching/Volo.Abp.Caching.csproj index e9a5acd990..f4417ae910 100644 --- a/framework/src/Volo.Abp.Caching/Volo.Abp.Caching.csproj +++ b/framework/src/Volo.Abp.Caching/Volo.Abp.Caching.csproj @@ -18,6 +18,7 @@ + diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs index 3a1537cba7..48d55cc0d5 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/AbpCachingModule.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using System; +using Volo.Abp.Json; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; using Volo.Abp.Serialization; @@ -7,9 +8,11 @@ using Volo.Abp.Threading; namespace Volo.Abp.Caching { - [DependsOn(typeof(AbpThreadingModule))] - [DependsOn(typeof(AbpSerializationModule))] - [DependsOn(typeof(AbpMultiTenancyModule))] + [DependsOn( + typeof(AbpThreadingModule), + typeof(AbpSerializationModule), + typeof(AbpMultiTenancyModule), + typeof(AbpJsonModule))] public class AbpCachingModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index f65683042b..75b024740c 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -25,11 +25,12 @@ namespace Volo.Abp.Caching protected ICancellationTokenProvider CancellationTokenProvider { get; } - protected IObjectSerializer ObjectSerializer { get; } + //TODO: Create IDistributedCacheSerializer + protected IDistributedCacheSerializer Serializer { get; } protected ICurrentTenant CurrentTenant { get; } - protected AsyncLock AsyncLock { get; } = new AsyncLock(); + //protected AsyncLock AsyncLock { get; } = new AsyncLock(); protected DistributedCacheEntryOptions DefaultCacheOptions; @@ -42,8 +43,7 @@ namespace Volo.Abp.Caching IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, - - IObjectSerializer objectSerializer, + IDistributedCacheSerializer serializer, ICurrentTenant currentTenant) { _distributedCacheOption = distributedCacheOption.Value; @@ -51,13 +51,15 @@ namespace Volo.Abp.Caching Cache = cache; CancellationTokenProvider = cancellationTokenProvider; Logger = NullLogger>.Instance; - ObjectSerializer = objectSerializer; + Serializer = serializer; CurrentTenant = currentTenant; SetDefaultOptions(); } - public virtual TCacheItem Get(string key, bool? hideErrors = null) + public virtual TCacheItem Get( + string key, + bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -83,10 +85,13 @@ namespace Volo.Abp.Caching return null; } - return ObjectSerializer.Deserialize(cachedBytes); + return Serializer.Deserialize(cachedBytes); } - public virtual async Task GetAsync(string key, bool? hideErrors = null, CancellationToken token = default) + public virtual async Task GetAsync( + string key, + bool? hideErrors = null, + CancellationToken token = default) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -115,7 +120,7 @@ namespace Volo.Abp.Caching return null; } - return ObjectSerializer.Deserialize(cachedBytes); + return Serializer.Deserialize(cachedBytes); } public TCacheItem GetOrAdd( @@ -130,7 +135,7 @@ namespace Volo.Abp.Caching return value; } - using (AsyncLock.Lock(CancellationTokenProvider.Token)) + //using (AsyncLock.Lock(CancellationTokenProvider.Token)) { value = Get(key, hideErrors); if (value != null) @@ -159,7 +164,7 @@ namespace Volo.Abp.Caching return value; } - using (await AsyncLock.LockAsync(token)) + //using (await AsyncLock.LockAsync(token)) { value = await GetAsync(key, hideErrors, token); if (value != null) @@ -174,7 +179,11 @@ namespace Volo.Abp.Caching return value; } - public virtual void Set(string key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null) + public virtual void Set( + string key, + TCacheItem value, + DistributedCacheEntryOptions options = null, + bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -182,7 +191,7 @@ namespace Volo.Abp.Caching { Cache.Set( NormalizeKey(key), - ObjectSerializer.Serialize(value), + Serializer.Serialize(value), options ?? DefaultCacheOptions ); } @@ -198,7 +207,12 @@ namespace Volo.Abp.Caching } } - public virtual async Task SetAsync(string key, TCacheItem value, DistributedCacheEntryOptions options = null, bool? hideErrors = null, CancellationToken token = default) + public virtual async Task SetAsync( + string key, + TCacheItem value, + DistributedCacheEntryOptions options = null, + bool? hideErrors = null, + CancellationToken token = default) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -206,7 +220,7 @@ namespace Volo.Abp.Caching { await Cache.SetAsync( NormalizeKey(key), - ObjectSerializer.Serialize(value), + Serializer.Serialize(value), options ?? DefaultCacheOptions, CancellationTokenProvider.FallbackToProvider(token) ); @@ -223,7 +237,9 @@ namespace Volo.Abp.Caching } } - public virtual void Refresh(string key, bool? hideErrors = null) + public virtual void Refresh( + string key, + bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -243,7 +259,10 @@ namespace Volo.Abp.Caching } } - public virtual async Task RefreshAsync(string key, bool? hideErrors = null, CancellationToken token = default) + public virtual async Task RefreshAsync( + string key, + bool? hideErrors = null, + CancellationToken token = default) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -263,7 +282,9 @@ namespace Volo.Abp.Caching } } - public virtual void Remove(string key, bool? hideErrors = null) + public virtual void Remove( + string key, + bool? hideErrors = null) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; @@ -282,7 +303,10 @@ namespace Volo.Abp.Caching } } - public virtual async Task RemoveAsync(string key, bool? hideErrors = null, CancellationToken token = default) + public virtual async Task RemoveAsync( + string key, + bool? hideErrors = null, + CancellationToken token = default) { hideErrors = hideErrors ?? _distributedCacheOption.HideErrors; diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCacheSerializer.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCacheSerializer.cs new file mode 100644 index 0000000000..a26620f17c --- /dev/null +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCacheSerializer.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.Caching +{ + public interface IDistributedCacheSerializer + { + byte[] Serialize(T obj); + + T Deserialize(byte[] bytes); + } +} diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/Utf8JsonDistributedCacheSerializer.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/Utf8JsonDistributedCacheSerializer.cs new file mode 100644 index 0000000000..a99127098f --- /dev/null +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/Utf8JsonDistributedCacheSerializer.cs @@ -0,0 +1,26 @@ +using System.Text; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Json; + +namespace Volo.Abp.Caching +{ + public class Utf8JsonDistributedCacheSerializer : IDistributedCacheSerializer, ITransientDependency + { + protected IJsonSerializer JsonSerializer { get; } + + public Utf8JsonDistributedCacheSerializer(IJsonSerializer jsonSerializer) + { + JsonSerializer = jsonSerializer; + } + + public byte[] Serialize(T obj) + { + return Encoding.UTF8.GetBytes(JsonSerializer.Serialize(obj)); + } + + public T Deserialize(byte[] bytes) + { + return (T)JsonSerializer.Deserialize(typeof(T), Encoding.UTF8.GetString(bytes)); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj index e119d294cc..71d48038e2 100644 --- a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj +++ b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj @@ -24,7 +24,7 @@ - - + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.MultiTenancy/System/Security/Principal/AbpClaimsIdentityExtensions.cs b/framework/src/Volo.Abp.MultiTenancy/System/Security/Principal/AbpClaimsIdentityExtensions.cs new file mode 100644 index 0000000000..5b9d2493b9 --- /dev/null +++ b/framework/src/Volo.Abp.MultiTenancy/System/Security/Principal/AbpClaimsIdentityExtensions.cs @@ -0,0 +1,25 @@ +using System.Security.Claims; +using JetBrains.Annotations; +using Volo.Abp.MultiTenancy; + +namespace System.Security.Principal +{ + public static class AbpMultiTenancyClaimsIdentityExtensions + { + public static MultiTenancySides GetMultiTenancySide([NotNull] this IIdentity identity) + { + var tenantId = identity.FindTenantId(); + return tenantId.HasValue + ? MultiTenancySides.Tenant + : MultiTenancySides.Host; + } + + public static MultiTenancySides GetMultiTenancySide([NotNull] this ClaimsPrincipal principal) + { + var tenantId = principal.FindTenantId(); + return tenantId.HasValue + ? MultiTenancySides.Tenant + : MultiTenancySides.Host; + } + } +} diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/_Layout.cshtml b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/_Layout.cshtml index c1fd7bd82b..9df9f9278f 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/_Layout.cshtml +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/Pages/_Layout.cshtml @@ -20,7 +20,7 @@ - @RenderSection("styles", false) + @await RenderSectionAsync("styles", false) @@ -30,7 +30,7 @@ - @RenderSection("scripts", false) + @await RenderSectionAsync("scripts", false) \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs index 6a68ebc91a..b7f1557ed9 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs @@ -1,4 +1,7 @@ -using Volo.Abp.IdentityServer; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Identity.AspNetCore; +using Volo.Abp.IdentityServer; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -10,12 +13,29 @@ namespace Volo.Abp.Account.Web )] public class AbpAccountWebIdentityServerModule : AbpModule { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + context.Services.PreConfigure(options => + { + options.ConfigureAuthentication = false; + }); + } + public override void ConfigureServices(ServiceConfigurationContext context) { Configure(options => { options.FileSets.AddEmbedded("Volo.Abp.Account.Web"); }); + + //TODO: Try to reuse from AbpIdentityAspNetCoreModule + context.Services + .AddAuthentication(o => + { + o.DefaultScheme = IdentityConstants.ApplicationScheme; + o.DefaultSignInScheme = IdentityConstants.ExternalScheme; + }) + .AddIdentityCookies(); } } } diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs index e999cf1450..846c31763c 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs @@ -1,7 +1,6 @@ using Localization.Resources.AbpUi; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Account.Web.Localization; -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; @@ -9,7 +8,6 @@ using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Localization; using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; -using Volo.Abp.Settings; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/PermissionTestDataBuilder.cs b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/PermissionTestDataBuilder.cs index 81fb98b2be..9d9e2ab10f 100644 --- a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/PermissionTestDataBuilder.cs +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/PermissionTestDataBuilder.cs @@ -29,6 +29,15 @@ namespace Volo.Abp.PermissionManagement User1Id.ToString() ) ); + + _permissionGrantRepository.Insert( + new PermissionGrant( + _guidGenerator.Create(), + "MyPermission3", + UserPermissionValueProvider.ProviderName, + User1Id.ToString() + ) + ); } } } \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs index bd997f76d4..5dfc6431c4 100644 --- a/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.TestBase/Volo/Abp/PermissionManagement/TestPermissionDefinitionProvider.cs @@ -1,4 +1,5 @@ using Volo.Abp.Authorization.Permissions; +using Volo.Abp.MultiTenancy; namespace Volo.Abp.PermissionManagement { @@ -12,6 +13,8 @@ namespace Volo.Abp.PermissionManagement var myPermission2 = testGroup.AddPermission("MyPermission2"); myPermission2.AddChild("MyPermission2.ChildPermission1"); + + testGroup.AddPermission("MyPermission3", multiTenancySide: MultiTenancySides.Host); } } } \ No newline at end of file diff --git a/modules/permission-management/test/Volo.Abp.PermissionManagement.Tests/Volo/Abp/PermissionManagement/PermissionChecker_User_Tests.cs b/modules/permission-management/test/Volo.Abp.PermissionManagement.Tests/Volo/Abp/PermissionManagement/PermissionChecker_User_Tests.cs index 280cc0d638..b49ff94f90 100644 --- a/modules/permission-management/test/Volo.Abp.PermissionManagement.Tests/Volo/Abp/PermissionManagement/PermissionChecker_User_Tests.cs +++ b/modules/permission-management/test/Volo.Abp.PermissionManagement.Tests/Volo/Abp/PermissionManagement/PermissionChecker_User_Tests.cs @@ -44,7 +44,16 @@ namespace Volo.Abp.PermissionManagement )).ShouldBeFalse(); } - private static ClaimsPrincipal CreatePrincipal(Guid? userId) + [Fact] + public async Task Should_Not_Allow_Host_Permission_To_Tenant_User_Even_Granted_Before() + { + (await _permissionChecker.IsGrantedAsync( + CreatePrincipal(PermissionTestDataBuilder.User1Id, Guid.NewGuid()), + "MyPermission3" + )).ShouldBeFalse(); + } + + private static ClaimsPrincipal CreatePrincipal(Guid? userId, Guid? tenantId = null) { var claimsIdentity = new ClaimsIdentity(); @@ -53,6 +62,11 @@ namespace Volo.Abp.PermissionManagement claimsIdentity.AddClaim(new Claim(AbpClaimTypes.UserId, userId.ToString())); } + if (tenantId != null) + { + claimsIdentity.AddClaim(new Claim(AbpClaimTypes.TenantId, tenantId.ToString())); + } + return new ClaimsPrincipal(claimsIdentity); } } diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.Designer.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.Designer.cs new file mode 100644 index 0000000000..4dac4a6a72 --- /dev/null +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.Designer.cs @@ -0,0 +1,1227 @@ +// +using System; +using AuthServer.Host.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace AuthServer.Host.Migrations +{ + [DbContext(typeof(AuthServerDbContext))] + [Migration("20190404130536_Make_IDS4_Entities_Audited")] + partial class Make_IDS4_Entities_Audited + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApplicationName") + .HasColumnName("ApplicationName") + .HasMaxLength(96); + + b.Property("BrowserInfo") + .HasColumnName("BrowserInfo") + .HasMaxLength(512); + + b.Property("ClientId") + .HasColumnName("ClientId") + .HasMaxLength(64); + + b.Property("ClientIpAddress") + .HasColumnName("ClientIpAddress") + .HasMaxLength(64); + + b.Property("ClientName") + .HasColumnName("ClientName") + .HasMaxLength(128); + + b.Property("Comments") + .HasColumnName("Comments") + .HasMaxLength(256); + + b.Property("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasColumnName("CorrelationId") + .HasMaxLength(64); + + b.Property("Exceptions") + .HasColumnName("Exceptions") + .HasMaxLength(4000); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("HttpMethod") + .HasColumnName("HttpMethod") + .HasMaxLength(16); + + b.Property("HttpStatusCode") + .HasColumnName("HttpStatusCode"); + + b.Property("ImpersonatorTenantId") + .HasColumnName("ImpersonatorTenantId"); + + b.Property("ImpersonatorUserId") + .HasColumnName("ImpersonatorUserId"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.Property("TenantName"); + + b.Property("Url") + .HasColumnName("Url") + .HasMaxLength(256); + + b.Property("UserId") + .HasColumnName("UserId"); + + b.Property("UserName") + .HasColumnName("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ExecutionTime"); + + b.HasIndex("TenantId", "UserId", "ExecutionTime"); + + b.ToTable("AbpAuditLogs"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime") + .HasColumnName("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("MethodName") + .HasColumnName("MethodName") + .HasMaxLength(128); + + b.Property("Parameters") + .HasColumnName("Parameters") + .HasMaxLength(2000); + + b.Property("ServiceName") + .HasColumnName("ServiceName") + .HasMaxLength(256); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "ServiceName", "MethodName", "ExecutionTime"); + + b.ToTable("AbpAuditLogActions"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ChangeTime") + .HasColumnName("ChangeTime"); + + b.Property("ChangeType") + .HasColumnName("ChangeType"); + + b.Property("EntityId") + .IsRequired() + .HasColumnName("EntityId") + .HasMaxLength(128); + + b.Property("EntityTenantId"); + + b.Property("EntityTypeFullName") + .IsRequired() + .HasColumnName("EntityTypeFullName") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "EntityTypeFullName", "EntityId"); + + b.ToTable("AbpEntityChanges"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EntityChangeId"); + + b.Property("NewValue") + .HasColumnName("NewValue") + .HasMaxLength(512); + + b.Property("OriginalValue") + .HasColumnName("OriginalValue") + .HasMaxLength(512); + + b.Property("PropertyName") + .IsRequired() + .HasColumnName("PropertyName") + .HasMaxLength(128); + + b.Property("PropertyTypeFullName") + .IsRequired() + .HasColumnName("PropertyTypeFullName") + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityChangeId"); + + b.ToTable("AbpEntityPropertyChanges"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256); + + b.Property("Regex") + .HasMaxLength(512); + + b.Property("RegexDescription") + .HasMaxLength(128); + + b.Property("Required"); + + b.Property("ValueType"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasColumnName("ConcurrencyStamp") + .HasMaxLength(256); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256); + + b.Property("ClaimValue") + .HasMaxLength(1024); + + b.Property("RoleId"); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnName("AccessFailedCount") + .HasDefaultValue(0); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .HasColumnName("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnName("EmailConfirmed") + .HasDefaultValue(false); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnName("LockoutEnabled") + .HasDefaultValue(false); + + b.Property("LockoutEnd"); + + b.Property("Name") + .HasColumnName("Name") + .HasMaxLength(64); + + b.Property("NormalizedEmail") + .HasColumnName("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnName("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash") + .HasColumnName("PasswordHash") + .HasMaxLength(256); + + b.Property("PhoneNumber") + .HasColumnName("PhoneNumber") + .HasMaxLength(16); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnName("PhoneNumberConfirmed") + .HasDefaultValue(false); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnName("SecurityStamp") + .HasMaxLength(256); + + b.Property("Surname") + .HasColumnName("Surname") + .HasMaxLength(64); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnName("TwoFactorEnabled") + .HasDefaultValue(false); + + b.Property("UserName") + .IsRequired() + .HasColumnName("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256); + + b.Property("ClaimValue") + .HasMaxLength(1024); + + b.Property("TenantId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId"); + + b.Property("LoginProvider") + .HasMaxLength(64); + + b.Property("ProviderDisplayName") + .HasMaxLength(128); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196); + + b.Property("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.Property("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider") + .HasMaxLength(64); + + b.Property("Name") + .HasMaxLength(128); + + b.Property("TenantId"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Enabled"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.HasKey("Id"); + + b.ToTable("IdentityServerApiResources"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.Property("ApiResourceId"); + + b.Property("Type") + .HasMaxLength(196); + + b.HasKey("ApiResourceId", "Type"); + + b.ToTable("IdentityServerApiClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.Property("ApiResourceId"); + + b.Property("Name") + .HasMaxLength(196); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("DisplayName") + .HasMaxLength(128); + + b.Property("Emphasize"); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("ApiResourceId", "Name"); + + b.ToTable("IdentityServerApiScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.Property("ApiResourceId"); + + b.Property("Name") + .HasMaxLength(196); + + b.Property("Type") + .HasMaxLength(196); + + b.HasKey("ApiResourceId", "Name", "Type"); + + b.ToTable("IdentityServerApiScopeClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.Property("ApiResourceId"); + + b.Property("Type") + .HasMaxLength(32); + + b.Property("Value") + .HasMaxLength(196); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("Expiration"); + + b.HasKey("ApiResourceId", "Type", "Value"); + + b.ToTable("IdentityServerApiSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AbsoluteRefreshTokenLifetime"); + + b.Property("AccessTokenLifetime"); + + b.Property("AccessTokenType"); + + b.Property("AllowAccessTokensViaBrowser"); + + b.Property("AllowOfflineAccess"); + + b.Property("AllowPlainTextPkce"); + + b.Property("AllowRememberConsent"); + + b.Property("AlwaysIncludeUserClaimsInIdToken"); + + b.Property("AlwaysSendClientClaims"); + + b.Property("AuthorizationCodeLifetime"); + + b.Property("BackChannelLogoutSessionRequired"); + + b.Property("BackChannelLogoutUri") + .HasMaxLength(300); + + b.Property("ClientClaimsPrefix") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("ClientName") + .HasMaxLength(200); + + b.Property("ClientUri") + .HasMaxLength(300); + + b.Property("ConcurrencyStamp"); + + b.Property("ConsentLifetime"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("EnableLocalLogin"); + + b.Property("Enabled"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("FrontChannelLogoutSessionRequired"); + + b.Property("FrontChannelLogoutUri") + .HasMaxLength(300); + + b.Property("IdentityTokenLifetime"); + + b.Property("IncludeJwtId"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasMaxLength(300); + + b.Property("PairWiseSubjectSalt") + .HasMaxLength(200); + + b.Property("ProtocolType") + .IsRequired() + .HasMaxLength(200); + + b.Property("RefreshTokenExpiration"); + + b.Property("RefreshTokenUsage"); + + b.Property("RequireClientSecret"); + + b.Property("RequireConsent"); + + b.Property("RequirePkce"); + + b.Property("SlidingRefreshTokenLifetime"); + + b.Property("UpdateAccessTokenClaimsOnRefresh"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique(); + + b.ToTable("IdentityServerClients"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.Property("ClientId"); + + b.Property("Type") + .HasMaxLength(250); + + b.Property("Value") + .HasMaxLength(250); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.Property("ClientId"); + + b.Property("Origin") + .HasMaxLength(150); + + b.HasKey("ClientId", "Origin"); + + b.ToTable("IdentityServerClientCorsOrigins"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.Property("ClientId"); + + b.Property("GrantType") + .HasMaxLength(196); + + b.HasKey("ClientId", "GrantType"); + + b.ToTable("IdentityServerClientGrantTypes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.Property("ClientId"); + + b.Property("Provider") + .HasMaxLength(64); + + b.HasKey("ClientId", "Provider"); + + b.ToTable("IdentityServerClientIdPRestrictions"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.Property("ClientId"); + + b.Property("PostLogoutRedirectUri") + .HasMaxLength(200); + + b.HasKey("ClientId", "PostLogoutRedirectUri"); + + b.ToTable("IdentityServerClientPostLogoutRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.Property("ClientId"); + + b.Property("Key") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128); + + b.HasKey("ClientId", "Key"); + + b.ToTable("IdentityServerClientProperties"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.Property("ClientId"); + + b.Property("RedirectUri") + .HasMaxLength(200); + + b.HasKey("ClientId", "RedirectUri"); + + b.ToTable("IdentityServerClientRedirectUris"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.Property("ClientId"); + + b.Property("Scope") + .HasMaxLength(196); + + b.HasKey("ClientId", "Scope"); + + b.ToTable("IdentityServerClientScopes"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.Property("ClientId"); + + b.Property("Type") + .HasMaxLength(32); + + b.Property("Value") + .HasMaxLength(196); + + b.Property("Description") + .HasMaxLength(256); + + b.Property("Expiration"); + + b.HasKey("ClientId", "Type", "Value"); + + b.ToTable("IdentityServerClientSecrets"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Grants.PersistedGrant", b => + { + b.Property("Key") + .HasMaxLength(200); + + b.Property("ClientId") + .IsRequired() + .HasMaxLength(200); + + b.Property("ConcurrencyStamp"); + + b.Property("CreationTime"); + + b.Property("Data") + .IsRequired(); + + b.Property("Expiration"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("Id"); + + b.Property("SubjectId") + .HasMaxLength(200); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50); + + b.HasKey("Key"); + + b.HasIndex("SubjectId", "ClientId", "Type"); + + b.ToTable("IdentityServerPersistedGrants"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.Property("IdentityResourceId"); + + b.Property("Type") + .HasMaxLength(196); + + b.HasKey("IdentityResourceId", "Type"); + + b.ToTable("IdentityServerIdentityClaims"); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000); + + b.Property("DisplayName") + .HasMaxLength(200); + + b.Property("Emphasize"); + + b.Property("Enabled"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200); + + b.Property("Required"); + + b.Property("ShowInDiscoveryDocument"); + + b.HasKey("Id"); + + b.ToTable("IdentityServerIdentityResources"); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpPermissionGrants"); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .HasMaxLength(64); + + b.Property("ProviderName") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpSettings"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("Actions") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("EntityChanges") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.EntityChange") + .WithMany("PropertyChanges") + .HasForeignKey("EntityChangeId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole") + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser") + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Volo.Abp.Identity.IdentityUser") + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Scopes") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiScopeClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiScope") + .WithMany("UserClaims") + .HasForeignKey("ApiResourceId", "Name") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource") + .WithMany("Secrets") + .HasForeignKey("ApiResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Claims") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientCorsOrigin", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedCorsOrigins") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientGrantType", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedGrantTypes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientIdPRestriction", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("IdentityProviderRestrictions") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientPostLogoutRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("PostLogoutRedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientProperty", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("Properties") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientRedirectUri", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("RedirectUris") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientScope", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("AllowedScopes") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientSecret", b => + { + b.HasOne("Volo.Abp.IdentityServer.Clients.Client") + .WithMany("ClientSecrets") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.IdentityServer.IdentityResources.IdentityClaim", b => + { + b.HasOne("Volo.Abp.IdentityServer.IdentityResources.IdentityResource") + .WithMany("UserClaims") + .HasForeignKey("IdentityResourceId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.cs new file mode 100644 index 0000000000..5ef97dc0af --- /dev/null +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20190404130536_Make_IDS4_Entities_Audited.cs @@ -0,0 +1,347 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace AuthServer.Host.Migrations +{ + public partial class Make_IDS4_Entities_Audited : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CreationTime", + table: "IdentityServerIdentityResources", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "CreatorId", + table: "IdentityServerIdentityResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeleterId", + table: "IdentityServerIdentityResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeletionTime", + table: "IdentityServerIdentityResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "IdentityServerIdentityResources", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LastModificationTime", + table: "IdentityServerIdentityResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifierId", + table: "IdentityServerIdentityResources", + nullable: true); + + migrationBuilder.AlterColumn( + name: "LogoUri", + table: "IdentityServerClients", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 2000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FrontChannelLogoutUri", + table: "IdentityServerClients", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 2000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ClientUri", + table: "IdentityServerClients", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 2000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BackChannelLogoutUri", + table: "IdentityServerClients", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 2000, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CreationTime", + table: "IdentityServerClients", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "CreatorId", + table: "IdentityServerClients", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeleterId", + table: "IdentityServerClients", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeletionTime", + table: "IdentityServerClients", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "IdentityServerClients", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LastModificationTime", + table: "IdentityServerClients", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifierId", + table: "IdentityServerClients", + nullable: true); + + //migrationBuilder.AlterColumn( + // name: "RedirectUri", + // table: "IdentityServerClientRedirectUris", + // maxLength: 200, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 2000); + + //migrationBuilder.AlterColumn( + // name: "Value", + // table: "IdentityServerClientProperties", + // maxLength: 128, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 2000); + + //migrationBuilder.AlterColumn( + // name: "Key", + // table: "IdentityServerClientProperties", + // maxLength: 64, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 250); + + migrationBuilder.AddColumn( + name: "CreationTime", + table: "IdentityServerApiResources", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "CreatorId", + table: "IdentityServerApiResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeleterId", + table: "IdentityServerApiResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "DeletionTime", + table: "IdentityServerApiResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "IdentityServerApiResources", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LastModificationTime", + table: "IdentityServerApiResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "LastModifierId", + table: "IdentityServerApiResources", + nullable: true); + + migrationBuilder.AddColumn( + name: "EntityTenantId", + table: "AbpEntityChanges", + nullable: true); + + migrationBuilder.AddColumn( + name: "TenantName", + table: "AbpAuditLogs", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CreationTime", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "CreatorId", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "DeleterId", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "DeletionTime", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "LastModificationTime", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "LastModifierId", + table: "IdentityServerIdentityResources"); + + migrationBuilder.DropColumn( + name: "CreationTime", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "CreatorId", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "DeleterId", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "DeletionTime", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "LastModificationTime", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "LastModifierId", + table: "IdentityServerClients"); + + migrationBuilder.DropColumn( + name: "CreationTime", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "CreatorId", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "DeleterId", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "DeletionTime", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "LastModificationTime", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "LastModifierId", + table: "IdentityServerApiResources"); + + migrationBuilder.DropColumn( + name: "EntityTenantId", + table: "AbpEntityChanges"); + + migrationBuilder.DropColumn( + name: "TenantName", + table: "AbpAuditLogs"); + + migrationBuilder.AlterColumn( + name: "LogoUri", + table: "IdentityServerClients", + maxLength: 2000, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 300, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FrontChannelLogoutUri", + table: "IdentityServerClients", + maxLength: 2000, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 300, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ClientUri", + table: "IdentityServerClients", + maxLength: 2000, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 300, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BackChannelLogoutUri", + table: "IdentityServerClients", + maxLength: 2000, + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 300, + oldNullable: true); + + //migrationBuilder.AlterColumn( + // name: "RedirectUri", + // table: "IdentityServerClientRedirectUris", + // maxLength: 2000, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 200); + + //migrationBuilder.AlterColumn( + // name: "Value", + // table: "IdentityServerClientProperties", + // maxLength: 2000, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 128); + + //migrationBuilder.AlterColumn( + // name: "Key", + // table: "IdentityServerClientProperties", + // maxLength: 250, + // nullable: false, + // oldClrType: typeof(string), + // oldMaxLength: 64); + } + } +} diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs index ee3cf09fd3..361a93da3b 100644 --- a/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs +++ b/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/AuthServerDbContextModelSnapshot.cs @@ -82,6 +82,8 @@ namespace AuthServer.Host.Migrations b.Property("TenantId") .HasColumnName("TenantId"); + b.Property("TenantName"); + b.Property("Url") .HasColumnName("Url") .HasMaxLength(256); @@ -161,6 +163,8 @@ namespace AuthServer.Host.Migrations .HasColumnName("EntityId") .HasMaxLength(128); + b.Property("EntityTenantId"); + b.Property("EntityTypeFullName") .IsRequired() .HasColumnName("EntityTypeFullName") @@ -520,6 +524,18 @@ namespace AuthServer.Host.Migrations b.Property("ConcurrencyStamp"); + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + b.Property("Description") .HasMaxLength(1000); @@ -531,6 +547,17 @@ namespace AuthServer.Host.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + b.Property("Name") .IsRequired() .HasMaxLength(200); @@ -639,7 +666,7 @@ namespace AuthServer.Host.Migrations b.Property("BackChannelLogoutSessionRequired"); b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ClientClaimsPrefix") .HasMaxLength(200); @@ -652,12 +679,24 @@ namespace AuthServer.Host.Migrations .HasMaxLength(200); b.Property("ClientUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ConcurrencyStamp"); b.Property("ConsentLifetime"); + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + b.Property("Description") .HasMaxLength(1000); @@ -671,14 +710,25 @@ namespace AuthServer.Host.Migrations b.Property("FrontChannelLogoutSessionRequired"); b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("IdentityTokenLifetime"); b.Property("IncludeJwtId"); + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + b.Property("LogoUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("PairWiseSubjectSalt") .HasMaxLength(200); @@ -777,11 +827,11 @@ namespace AuthServer.Host.Migrations b.Property("ClientId"); b.Property("Key") - .HasMaxLength(250); + .HasMaxLength(64); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(128); b.HasKey("ClientId", "Key"); @@ -793,7 +843,7 @@ namespace AuthServer.Host.Migrations b.Property("ClientId"); b.Property("RedirectUri") - .HasMaxLength(2000); + .HasMaxLength(200); b.HasKey("ClientId", "RedirectUri"); @@ -888,6 +938,18 @@ namespace AuthServer.Host.Migrations b.Property("ConcurrencyStamp"); + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnName("DeletionTime"); + b.Property("Description") .HasMaxLength(1000); @@ -901,6 +963,17 @@ namespace AuthServer.Host.Migrations b.Property("ExtraProperties") .HasColumnName("ExtraProperties"); + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnName("IsDeleted") + .HasDefaultValue(false); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + b.Property("Name") .IsRequired() .HasMaxLength(200);