diff --git a/Sample.sln b/Sample.sln index ce00b86..3c7258f 100644 --- a/Sample.sln +++ b/Sample.sln @@ -67,25 +67,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DictionaryM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DictionaryManagement.EntityFrameworkCore", "modules\dictionary-management\src\Passingwind.Abp.DictionaryManagement.EntityFrameworkCore\Passingwind.Abp.DictionaryManagement.EntityFrameworkCore.csproj", "{2DB157B1-1EF2-4548-A154-3F05263C338B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dynamic-permission-management", "dynamic-permission-management", "{0262B53C-3807-4ACC-B1E6-FCC0817B6971}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "permission-management", "permission-management", "{0262B53C-3807-4ACC-B1E6-FCC0817B6971}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E4E4978C-8541-4C36-B258-800A8B177769}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.Domain.Shared", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.Domain.Shared\Passingwind.Abp.DynamicPermissionManagement.Domain.Shared.csproj", "{41ED28CA-CB9A-446C-A63D-92D932195DD8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Domain.Shared", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.Domain.Shared\Passingwind.Abp.PermissionManagement.Domain.Shared.csproj", "{41ED28CA-CB9A-446C-A63D-92D932195DD8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.Domain", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.Domain\Passingwind.Abp.DynamicPermissionManagement.Domain.csproj", "{4C42EC8C-0DDE-48EB-A1A9-6B093A9E9666}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Domain", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.Domain\Passingwind.Abp.PermissionManagement.Domain.csproj", "{4C42EC8C-0DDE-48EB-A1A9-6B093A9E9666}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.Application.Contracts", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.Application.Contracts\Passingwind.Abp.DynamicPermissionManagement.Application.Contracts.csproj", "{12F3145F-76B7-46AF-B168-2F9265997F0A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Application.Contracts", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.Application.Contracts\Passingwind.Abp.PermissionManagement.Application.Contracts.csproj", "{12F3145F-76B7-46AF-B168-2F9265997F0A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.Application", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.Application\Passingwind.Abp.DynamicPermissionManagement.Application.csproj", "{50FBAE74-1A47-4F83-B3DC-CAADDF8BE11E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Application", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.Application\Passingwind.Abp.PermissionManagement.Application.csproj", "{50FBAE74-1A47-4F83-B3DC-CAADDF8BE11E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.EntityFrameworkCore", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.EntityFrameworkCore\Passingwind.Abp.DynamicPermissionManagement.EntityFrameworkCore.csproj", "{C96263B9-0FA9-4710-92D0-CDDD7400BD9B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.EntityFrameworkCore", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.EntityFrameworkCore\Passingwind.Abp.PermissionManagement.EntityFrameworkCore.csproj", "{C96263B9-0FA9-4710-92D0-CDDD7400BD9B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.MongoDB", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.MongoDB\Passingwind.Abp.DynamicPermissionManagement.MongoDB.csproj", "{A4BE1B4C-D3FF-45BA-8CCD-807BAAE3A441}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.MongoDB", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.MongoDB\Passingwind.Abp.PermissionManagement.MongoDB.csproj", "{A4BE1B4C-D3FF-45BA-8CCD-807BAAE3A441}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.HttpApi", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.HttpApi\Passingwind.Abp.DynamicPermissionManagement.HttpApi.csproj", "{18F8D5E8-54B4-4399-BC77-32A70DD286FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.HttpApi", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.HttpApi\Passingwind.Abp.PermissionManagement.HttpApi.csproj", "{18F8D5E8-54B4-4399-BC77-32A70DD286FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.DynamicPermissionManagement.HttpApi.Client", "modules\dynamic-permission-management\src\Passingwind.Abp.DynamicPermissionManagement.HttpApi.Client\Passingwind.Abp.DynamicPermissionManagement.HttpApi.Client.csproj", "{863B1141-4CAA-4AA1-8B5F-CD923AF67CD4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.HttpApi.Client", "modules\permission-management\src\Passingwind.Abp.PermissionManagement.HttpApi.Client\Passingwind.Abp.PermissionManagement.HttpApi.Client.csproj", "{863B1141-4CAA-4AA1-8B5F-CD923AF67CD4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "identity", "identity", "{4A4FBA8F-3B0A-4709-81EA-0238F219BA9F}" EndProject diff --git a/common.props b/common.props index 534e570..47076e9 100644 --- a/common.props +++ b/common.props @@ -3,6 +3,7 @@ 8.0.4 8.2.0 + enable - + \ No newline at end of file diff --git a/host/src/Sample.Application/Sample.Application.csproj b/host/src/Sample.Application/Sample.Application.csproj index 8e4adcb..b540126 100644 --- a/host/src/Sample.Application/Sample.Application.csproj +++ b/host/src/Sample.Application/Sample.Application.csproj @@ -14,6 +14,7 @@ + diff --git a/host/src/Sample.Application/SampleApplicationModule.cs b/host/src/Sample.Application/SampleApplicationModule.cs index 7be3d23..86061a3 100644 --- a/host/src/Sample.Application/SampleApplicationModule.cs +++ b/host/src/Sample.Application/SampleApplicationModule.cs @@ -3,6 +3,7 @@ using Passingwind.Abp.FileManagement; using Passingwind.Abp.Identity; using Passingwind.Abp.IdentityClient; +using Passingwind.Abp.PermissionManagement; using Volo.Abp.Account; using Volo.Abp.AutoMapper; using Volo.Abp.FeatureManagement; @@ -29,6 +30,7 @@ namespace Sample; [DependsOn(typeof(FileManagementApplicationModule))] [DependsOn(typeof(IdentityApplicationModule))] [DependsOn(typeof(IdentityClientApplicationModule))] +[DependsOn(typeof(PermissionManagementApplicationModule))] public class SampleApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/host/src/Sample.Domain/Sample.Domain.csproj b/host/src/Sample.Domain/Sample.Domain.csproj index e51346d..a42b0f2 100644 --- a/host/src/Sample.Domain/Sample.Domain.csproj +++ b/host/src/Sample.Domain/Sample.Domain.csproj @@ -14,6 +14,7 @@ + diff --git a/host/src/Sample.Domain/SampleDomainModule.cs b/host/src/Sample.Domain/SampleDomainModule.cs index adb60fb..5696ea7 100644 --- a/host/src/Sample.Domain/SampleDomainModule.cs +++ b/host/src/Sample.Domain/SampleDomainModule.cs @@ -4,6 +4,7 @@ using Passingwind.Abp.FileManagement; using Passingwind.Abp.Identity; using Passingwind.Abp.IdentityClient; +using Passingwind.Abp.PermissionManagement; using Sample.MultiTenancy; using Volo.Abp.AuditLogging; using Volo.Abp.BackgroundJobs; @@ -38,6 +39,7 @@ namespace Sample; [DependsOn(typeof(FileManagementDomainModule))] [DependsOn(typeof(IdentityClientDomainModule))] [DependsOn(typeof(IdentityDomainModule))] +[DependsOn(typeof(PermissionManagementDomainModule))] public class SampleDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleDbContext.cs b/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleDbContext.cs index 2442441..488c4c2 100644 --- a/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleDbContext.cs +++ b/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleDbContext.cs @@ -3,6 +3,7 @@ using Passingwind.Abp.FileManagement.EntityFrameworkCore; using Passingwind.Abp.Identity.EntityFrameworkCore; using Passingwind.Abp.IdentityClient.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.BackgroundJobs.EntityFrameworkCore; using Volo.Abp.Data; @@ -86,6 +87,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.ConfigureIdentityClient(); modelBuilder.ConfigureApiKey(); modelBuilder.ConfigureIdentityV2(); + modelBuilder.ConfigurePermissionManagementV2(); /* Configure your own tables/entities inside here */ diff --git a/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleEntityFrameworkCoreModule.cs b/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleEntityFrameworkCoreModule.cs index ac0505e..c7df91a 100644 --- a/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleEntityFrameworkCoreModule.cs +++ b/host/src/Sample.EntityFrameworkCore/EntityFrameworkCore/SampleEntityFrameworkCoreModule.cs @@ -3,6 +3,7 @@ using Passingwind.Abp.FileManagement.EntityFrameworkCore; using Passingwind.Abp.Identity.EntityFrameworkCore; using Passingwind.Abp.IdentityClient.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.BackgroundJobs.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; @@ -33,6 +34,7 @@ namespace Sample.EntityFrameworkCore; [DependsOn(typeof(FileManagementEntityFrameworkCoreModule))] [DependsOn(typeof(IdentityClientEntityFrameworkCoreModule))] [DependsOn(typeof(IdentityEntityFrameworkCoreModule))] +[DependsOn(typeof(PermissionManagementEntityFrameworkCoreModule))] public class SampleEntityFrameworkCoreModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) diff --git a/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.Designer.cs b/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.Designer.cs new file mode 100644 index 0000000..09bb276 --- /dev/null +++ b/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.Designer.cs @@ -0,0 +1,2669 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sample.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace Sample.Migrations +{ + [DbContext(typeof(SampleDbContext))] + [Migration("20240707111959_Add_PermissionManagement")] + partial class Add_PermissionManagement + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Passingwind.Abp.ApiKey.ApiKeyRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("ExpirationTime") + .HasColumnType("datetime2"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Secret") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CreationTime") + .IsDescending(); + + b.HasIndex("Name"); + + b.HasIndex("Secret"); + + b.ToTable("PassingwindApiKeys", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.FileManagement.Files.File", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BlobName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Hash") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsDirectory") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Length") + .HasColumnType("bigint"); + + b.Property("MimeType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UniqueId") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("CreationTime") + .IsDescending(); + + b.HasIndex("FileName"); + + b.HasIndex("Hash"); + + b.HasIndex("UniqueId"); + + b.ToTable("FmFiles", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.FileManagement.Files.FileAccessToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DownloadCount") + .HasColumnType("bigint"); + + b.Property("ExpirationTime") + .HasColumnType("datetime2"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("Token") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("FileId"); + + b.HasIndex("Token"); + + b.ToTable("FmFileAccessTokens", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.FileManagement.Files.FileContainer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccessMode") + .HasColumnType("int"); + + b.Property("AllowAnyFileExtension") + .HasColumnType("bit"); + + b.Property("AllowedFileExtensions") + .HasColumnType("nvarchar(max)"); + + b.Property("AutoDeleteBlob") + .HasColumnType("bit"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("FilesCount") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaximumEachFileSize") + .HasColumnType("bigint"); + + b.Property("MaximumFileQuantity") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OverrideBehavior") + .HasColumnType("int"); + + b.Property("ProhibitedFileExtensions") + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("FmFileContainers", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.Identity.IdentityUserTwoFactor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("EmailToken") + .HasColumnType("bit"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("PhoneNumberToken") + .HasColumnType("bit"); + + b.Property("PreferredProvider") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AbpUserTwoFactors", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("DisplayOrder") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDebugMode") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderType") + .HasColumnType("int"); + + b.Property("RequiredClaimTypes") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("CreationTime") + .IsDescending(); + + b.HasIndex("Name"); + + b.HasIndex("ProviderName"); + + b.ToTable("PassingwindIdentityClients", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClientClaimMap", b => + { + b.Property("IdentityClientId") + .HasColumnType("uniqueidentifier"); + + b.Property("ClaimType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("RawValue") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ValueFromType") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("IdentityClientId", "ClaimType"); + + b.ToTable("PassingwindIdentityClientClaimMaps", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClientConfiguration", b => + { + b.Property("IdentityClientId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("IdentityClientId", "Name"); + + b.ToTable("PassingwindIdentityClientConfigurations", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.PermissionManagement.DynamicPermissions.DynamicPermissionDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("TargetName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("AbpDynamicPermissions", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.PermissionManagement.DynamicPermissions.DynamicPermissionGroupDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TargetName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpDynamicPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("nvarchar(96)") + .HasColumnName("ApplicationName"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasColumnName("BrowserInfo"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("ClientId"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("ClientIpAddress"); + + b.Property("ClientName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("ClientName"); + + b.Property("Comments") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("Comments"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("CorrelationId"); + + b.Property("Exceptions") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionDuration") + .HasColumnType("int") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime") + .HasColumnType("datetime2"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("HttpMethod") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)") + .HasColumnName("HttpMethod"); + + b.Property("HttpStatusCode") + .HasColumnType("int") + .HasColumnName("HttpStatusCode"); + + b.Property("ImpersonatorTenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("ImpersonatorTenantId"); + + b.Property("ImpersonatorTenantName") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("ImpersonatorTenantName"); + + b.Property("ImpersonatorUserId") + .HasColumnType("uniqueidentifier") + .HasColumnName("ImpersonatorUserId"); + + b.Property("ImpersonatorUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("ImpersonatorUserName"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("TenantName"); + + b.Property("Url") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("Url"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier") + .HasColumnName("UserId"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ExecutionTime"); + + b.HasIndex("TenantId", "UserId", "ExecutionTime"); + + b.ToTable("AbpAuditLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AuditLogId") + .HasColumnType("uniqueidentifier") + .HasColumnName("AuditLogId"); + + b.Property("ExecutionDuration") + .HasColumnType("int") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime") + .HasColumnType("datetime2") + .HasColumnName("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("MethodName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("MethodName"); + + b.Property("Parameters") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)") + .HasColumnName("Parameters"); + + b.Property("ServiceName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("ServiceName"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "ServiceName", "MethodName", "ExecutionTime"); + + b.ToTable("AbpAuditLogActions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AuditLogId") + .HasColumnType("uniqueidentifier") + .HasColumnName("AuditLogId"); + + b.Property("ChangeTime") + .HasColumnType("datetime2") + .HasColumnName("ChangeTime"); + + b.Property("ChangeType") + .HasColumnType("tinyint") + .HasColumnName("ChangeType"); + + b.Property("EntityId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("EntityId"); + + b.Property("EntityTenantId") + .HasColumnType("uniqueidentifier"); + + b.Property("EntityTypeFullName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("EntityTypeFullName"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "EntityTypeFullName", "EntityId"); + + b.ToTable("AbpEntityChanges", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EntityChangeId") + .HasColumnType("uniqueidentifier"); + + b.Property("NewValue") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasColumnName("NewValue"); + + b.Property("OriginalValue") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)") + .HasColumnName("OriginalValue"); + + b.Property("PropertyName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("PropertyName"); + + b.Property("PropertyTypeFullName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("PropertyTypeFullName"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityChangeId"); + + b.ToTable("AbpEntityPropertyChanges", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.BackgroundJobs.BackgroundJobRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsAbandoned") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("JobArgs") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("nvarchar(max)"); + + b.Property("JobName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("LastTryTime") + .HasColumnType("datetime2"); + + b.Property("NextTryTime") + .HasColumnType("datetime2"); + + b.Property("Priority") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint") + .HasDefaultValue((byte)15); + + b.Property("TryCount") + .ValueGeneratedOnAdd() + .HasColumnType("smallint") + .HasDefaultValue((short)0); + + b.HasKey("Id"); + + b.HasIndex("IsAbandoned", "NextTryTime"); + + b.ToTable("AbpBackgroundJobs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AllowedProviders") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DefaultValue") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("IsAvailableToHost") + .HasColumnType("bit"); + + b.Property("IsVisibleToClients") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ValueType") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatures", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpFeatureGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique() + .HasFilter("[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + b.ToTable("AbpFeatureValues", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsStatic") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Regex") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("RegexDescription") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Required") + .HasColumnType("bit"); + + b.Property("ValueType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("AbpClaimTypes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityLinkUser", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("SourceTenantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SourceUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TargetTenantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TargetUserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId") + .IsUnique() + .HasFilter("[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + b.ToTable("AbpLinkUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDefault") + .HasColumnType("bit") + .HasColumnName("IsDefault"); + + b.Property("IsPublic") + .HasColumnType("bit") + .HasColumnName("IsPublic"); + + b.Property("IsStatic") + .HasColumnType("bit") + .HasColumnName("IsStatic"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AbpRoleClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySecurityLog", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Action") + .HasMaxLength(96) + .HasColumnType("nvarchar(96)"); + + b.Property("ApplicationName") + .HasMaxLength(96) + .HasColumnType("nvarchar(96)"); + + b.Property("BrowserInfo") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ClientIpAddress") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreationTime") + .HasColumnType("datetime2"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("Identity") + .HasMaxLength(96) + .HasColumnType("nvarchar(96)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TenantName") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Action"); + + b.HasIndex("TenantId", "ApplicationName"); + + b.HasIndex("TenantId", "Identity"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSecurityLogs", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentitySession", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ClientId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Device") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("DeviceInfo") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("IpAddresses") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("LastAccessed") + .HasColumnType("datetime2"); + + b.Property("SessionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("SignedIn") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("Device"); + + b.HasIndex("SessionId"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AbpSessions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0) + .HasColumnName("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("Email"); + + b.Property("EmailConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("EmailConfirmed"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsActive") + .HasColumnType("bit") + .HasColumnName("IsActive"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("IsExternal") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsExternal"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("LastPasswordChangeTime") + .HasColumnType("datetimeoffset"); + + b.Property("LockoutEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("LockoutEnabled"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("Name"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("NormalizedEmail"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("NormalizedUserName"); + + b.Property("PasswordHash") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("PasswordHash"); + + b.Property("PhoneNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)") + .HasColumnName("PhoneNumber"); + + b.Property("PhoneNumberConfirmed") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("PhoneNumberConfirmed"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("SecurityStamp"); + + b.Property("ShouldChangePasswordOnNextLogin") + .HasColumnType("bit"); + + b.Property("Surname") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)") + .HasColumnName("Surname"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("TwoFactorEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("TwoFactorEnabled"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)") + .HasColumnName("UserName"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("NormalizedEmail"); + + b.HasIndex("NormalizedUserName"); + + b.HasIndex("UserName"); + + b.ToTable("AbpUsers", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ClaimType") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ClaimValue") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AbpUserClaims", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserDelegation", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("SourceUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.Property("TargetUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.ToTable("AbpUserDelegations", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ProviderDisplayName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(196) + .HasColumnType("nvarchar(196)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "LoginProvider"); + + b.HasIndex("LoginProvider", "ProviderKey"); + + b.ToTable("AbpUserLogins", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "UserId"); + + b.HasIndex("UserId", "OrganizationUnitId"); + + b.ToTable("AbpUserOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId", "UserId"); + + b.ToTable("AbpUserRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("LoginProvider") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AbpUserTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(95) + .HasColumnType("nvarchar(95)") + .HasColumnName("Code"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)") + .HasColumnName("DisplayName"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Code"); + + b.HasIndex("ParentId"); + + b.ToTable("AbpOrganizationUnits", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.Property("OrganizationUnitId") + .HasColumnType("uniqueidentifier"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("OrganizationUnitId", "RoleId"); + + b.HasIndex("RoleId", "OrganizationUnitId"); + + b.ToTable("AbpOrganizationUnitRoles", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ApplicationType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ClientSecret") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ClientUri") + .HasColumnType("nvarchar(max)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("JsonWebKeySet") + .HasColumnType("nvarchar(max)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("LogoUri") + .HasColumnType("nvarchar(max)"); + + b.Property("Permissions") + .HasColumnType("nvarchar(max)"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Requirements") + .HasColumnType("nvarchar(max)"); + + b.Property("Settings") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("OpenIddictApplications", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ApplicationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Scopes") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Scopes.OpenIddictScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Descriptions") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Resources") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("OpenIddictScopes", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ApplicationId") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorizationId") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Payload") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedemptionDate") + .HasColumnType("datetime2"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("MultiTenancySide") + .HasColumnType("tinyint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Providers") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("StateCheckers") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("GroupName"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") + .IsUnique() + .HasFilter("[TenantId] IS NOT NULL"); + + b.ToTable("AbpPermissionGrants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpPermissionGroups", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ProviderName") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey") + .IsUnique() + .HasFilter("[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + b.ToTable("AbpSettings", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.SettingDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DefaultValue") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("Description") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("ExtraProperties") + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsEncrypted") + .HasColumnType("bit"); + + b.Property("IsInherited") + .HasColumnType("bit"); + + b.Property("IsVisibleToClients") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Providers") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpSettingDefinitions", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("EntityVersion") + .HasColumnType("int"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.HasIndex("NormalizedName"); + + b.ToTable("AbpTenants", (string)null); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.Property("TenantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.HasKey("TenantId", "Name"); + + b.ToTable("AbpTenantConnectionStrings", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClientClaimMap", b => + { + b.HasOne("Passingwind.Abp.IdentityClient.IdentityClient", null) + .WithMany("ClaimMaps") + .HasForeignKey("IdentityClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClientConfiguration", b => + { + b.HasOne("Passingwind.Abp.IdentityClient.IdentityClient", null) + .WithMany("Configurations") + .HasForeignKey("IdentityClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog", null) + .WithMany("Actions") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog", null) + .WithMany("EntityChanges") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.EntityChange", null) + .WithMany("PropertyChanges") + .HasForeignKey("EntityChangeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany("Claims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Claims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("OrganizationUnits") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b => + { + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Roles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b => + { + b.HasOne("Volo.Abp.Identity.IdentityUser", null) + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany() + .HasForeignKey("ParentId"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b => + { + b.HasOne("Volo.Abp.Identity.OrganizationUnit", null) + .WithMany("Roles") + .HasForeignKey("OrganizationUnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Volo.Abp.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + }); + + modelBuilder.Entity("Volo.Abp.OpenIddict.Tokens.OpenIddictToken", b => + { + b.HasOne("Volo.Abp.OpenIddict.Applications.OpenIddictApplication", null) + .WithMany() + .HasForeignKey("ApplicationId"); + + b.HasOne("Volo.Abp.OpenIddict.Authorizations.OpenIddictAuthorization", null) + .WithMany() + .HasForeignKey("AuthorizationId"); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.TenantConnectionString", b => + { + b.HasOne("Volo.Abp.TenantManagement.Tenant", null) + .WithMany("ConnectionStrings") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Passingwind.Abp.IdentityClient.IdentityClient", b => + { + b.Navigation("ClaimMaps"); + + b.Navigation("Configurations"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => + { + b.Navigation("Actions"); + + b.Navigation("EntityChanges"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.Navigation("PropertyChanges"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b => + { + b.Navigation("Claims"); + + b.Navigation("Logins"); + + b.Navigation("OrganizationUnits"); + + b.Navigation("Roles"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Volo.Abp.TenantManagement.Tenant", b => + { + b.Navigation("ConnectionStrings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.cs b/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.cs new file mode 100644 index 0000000..ad9c70e --- /dev/null +++ b/host/src/Sample.EntityFrameworkCore/Migrations/20240707111959_Add_PermissionManagement.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Sample.Migrations; + +/// +public partial class Add_PermissionManagement : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AbpDynamicPermissionGroups", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TargetName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: false), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_AbpDynamicPermissionGroups", x => x.Id)); + + migrationBuilder.CreateTable( + name: "AbpDynamicPermissions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TargetName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + DisplayName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + GroupId = table.Column(type: "uniqueidentifier", nullable: false), + IsEnabled = table.Column(type: "bit", nullable: false), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: false), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => table.PrimaryKey("PK_AbpDynamicPermissions", x => x.Id)); + + migrationBuilder.CreateIndex( + name: "IX_AbpDynamicPermissionGroups_Name", + table: "AbpDynamicPermissionGroups", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpDynamicPermissions_GroupId", + table: "AbpDynamicPermissions", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpDynamicPermissions_Name", + table: "AbpDynamicPermissions", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AbpDynamicPermissions_ParentId", + table: "AbpDynamicPermissions", + column: "ParentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpDynamicPermissionGroups"); + + migrationBuilder.DropTable( + name: "AbpDynamicPermissions"); + } +} diff --git a/host/src/Sample.EntityFrameworkCore/Migrations/SampleDbContextModelSnapshot.cs b/host/src/Sample.EntityFrameworkCore/Migrations/SampleDbContextModelSnapshot.cs index 628ba37..33cc1da 100644 --- a/host/src/Sample.EntityFrameworkCore/Migrations/SampleDbContextModelSnapshot.cs +++ b/host/src/Sample.EntityFrameworkCore/Migrations/SampleDbContextModelSnapshot.cs @@ -527,6 +527,137 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("PassingwindIdentityClientConfigurations", (string)null); }); + modelBuilder.Entity("Passingwind.Abp.PermissionManagement.DynamicPermissions.DynamicPermissionDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("TargetName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.ToTable("AbpDynamicPermissions", (string)null); + }); + + modelBuilder.Entity("Passingwind.Abp.PermissionManagement.DynamicPermissions.DynamicPermissionGroupDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ExtraProperties") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TargetName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AbpDynamicPermissionGroups", (string)null); + }); + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => { b.Property("Id") diff --git a/host/src/Sample.EntityFrameworkCore/Sample.EntityFrameworkCore.csproj b/host/src/Sample.EntityFrameworkCore/Sample.EntityFrameworkCore.csproj index 0749e15..4b3422b 100644 --- a/host/src/Sample.EntityFrameworkCore/Sample.EntityFrameworkCore.csproj +++ b/host/src/Sample.EntityFrameworkCore/Sample.EntityFrameworkCore.csproj @@ -13,6 +13,7 @@ + diff --git a/host/src/Sample.HttpApi.Host/Sample.HttpApi.Host.csproj b/host/src/Sample.HttpApi.Host/Sample.HttpApi.Host.csproj index 14effd9..e17cca8 100644 --- a/host/src/Sample.HttpApi.Host/Sample.HttpApi.Host.csproj +++ b/host/src/Sample.HttpApi.Host/Sample.HttpApi.Host.csproj @@ -33,6 +33,7 @@ + diff --git a/host/src/Sample.HttpApi.Host/SampleHttpApiHostModule.cs b/host/src/Sample.HttpApi.Host/SampleHttpApiHostModule.cs index 5ee4d64..422b87f 100644 --- a/host/src/Sample.HttpApi.Host/SampleHttpApiHostModule.cs +++ b/host/src/Sample.HttpApi.Host/SampleHttpApiHostModule.cs @@ -4,8 +4,10 @@ using System.Linq; using Hangfire; using Hangfire.MemoryStorage; +using Microsoft.AspNetCore.Antiforgery; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -14,7 +16,7 @@ using Passingwind.Abp.ApiKey; using Passingwind.Abp.FileManagement; using Passingwind.Abp.FileManagement.Options; -using Passingwind.Abp.IdentityClient; +using Passingwind.Abp.PermissionManagement; using Passingwind.AspNetCore.Authentication.ApiKey; using Sample.EntityFrameworkCore; using Sample.MultiTenancy; @@ -23,6 +25,7 @@ using Volo.Abp.Account; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.AntiForgery; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; @@ -56,6 +59,7 @@ namespace Sample; [DependsOn(typeof(FileManagementApplicationModule))] [DependsOn(typeof(AccountAspNetCoreIdentityClientModule))] [DependsOn(typeof(AccountAspNetCoreModule))] +[DependsOn(typeof(PermissionManagementHttpApiModule))] public class SampleHttpApiHostModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) @@ -103,6 +107,14 @@ public override void ConfigureServices(ServiceConfigurationContext context) .UseRecommendedSerializerSettings() .UseColouredConsoleLogProvider(); }); + + Configure(options => + { + options.MinimumSameSitePolicy = SameSiteMode.Lax; + options.Secure = CookieSecurePolicy.SameAsRequest; + }); + + Configure(options => options.TokenCookie.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax); } private void ConfigureAuthentication(ServiceConfigurationContext context) diff --git a/modules/permission-management/Passingwind.Abp.PermissionManagement.sln b/modules/permission-management/Passingwind.Abp.PermissionManagement.sln new file mode 100644 index 0000000..3e397c1 --- /dev/null +++ b/modules/permission-management/Passingwind.Abp.PermissionManagement.sln @@ -0,0 +1,123 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Domain.Shared", "src\Passingwind.Abp.PermissionManagement.Domain.Shared\Passingwind.Abp.PermissionManagement.Domain.Shared.csproj", "{D64C1577-4929-4B60-939E-96DE1534891A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Domain", "src\Passingwind.Abp.PermissionManagement.Domain\Passingwind.Abp.PermissionManagement.Domain.csproj", "{F2840BC7-0188-4606-9126-DADD0F5ABF7A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Application.Contracts", "src\Passingwind.Abp.PermissionManagement.Application.Contracts\Passingwind.Abp.PermissionManagement.Application.Contracts.csproj", "{BD65D04F-08D5-40C1-8C24-77CA0BACB877}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Application", "src\Passingwind.Abp.PermissionManagement.Application\Passingwind.Abp.PermissionManagement.Application.csproj", "{78040F9E-3501-4A40-82DF-00A597710F35}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{649A3FFA-182F-4E56-9717-E6A9A2BEC545}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.EntityFrameworkCore", "src\Passingwind.Abp.PermissionManagement.EntityFrameworkCore\Passingwind.Abp.PermissionManagement.EntityFrameworkCore.csproj", "{0CE86223-D31D-4315-A1F5-87BA3EE1B844}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.MongoDB", "src\Passingwind.Abp.PermissionManagement.MongoDB\Passingwind.Abp.PermissionManagement.MongoDB.csproj", "{F1C58097-4C08-4D88-8976-6B3389391481}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.HttpApi", "src\Passingwind.Abp.PermissionManagement.HttpApi\Passingwind.Abp.PermissionManagement.HttpApi.csproj", "{077AA5F8-8B61-420C-A6B5-0150A66FDB34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.HttpApi.Client", "src\Passingwind.Abp.PermissionManagement.HttpApi.Client\Passingwind.Abp.PermissionManagement.HttpApi.Client.csproj", "{36E2735F-CEAB-44C8-A6D1-2CDAFF399751}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.TestBase", "test\Passingwind.Abp.PermissionManagement.TestBase\Passingwind.Abp.PermissionManagement.TestBase.csproj", "{C5BB573D-3030-4BCB-88B7-F6A85C32766C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests", "test\Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests\Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.csproj", "{527F645C-C1FC-406E-8479-81386C8ECF13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.MongoDB.Tests", "test\Passingwind.Abp.PermissionManagement.MongoDB.Tests\Passingwind.Abp.PermissionManagement.MongoDB.Tests.csproj", "{D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Domain.Tests", "test\Passingwind.Abp.PermissionManagement.Domain.Tests\Passingwind.Abp.PermissionManagement.Domain.Tests.csproj", "{E60895E5-79C4-447D-88B7-85CB5BA336A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Application.Tests", "test\Passingwind.Abp.PermissionManagement.Application.Tests\Passingwind.Abp.PermissionManagement.Application.Tests.csproj", "{90CB5DC4-C040-45C7-8900-9688B26405BC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Passingwind.Abp.PermissionManagement.Installer", "src\Passingwind.Abp.PermissionManagement.Installer\Passingwind.Abp.PermissionManagement.Installer.csproj", "{BE39FD00-745B-4049-8161-FC129817CBE4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.Build.0 = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.Build.0 = Release|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.Build.0 = Release|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.Build.0 = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.Build.0 = Release|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Release|Any CPU.Build.0 = Release|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Release|Any CPU.Build.0 = Release|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Release|Any CPU.Build.0 = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.Build.0 = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.Build.0 = Release|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Release|Any CPU.Build.0 = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.Build.0 = Release|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Release|Any CPU.Build.0 = Release|Any CPU + {BE39FD00-745B-4049-8161-FC129817CBE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE39FD00-745B-4049-8161-FC129817CBE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE39FD00-745B-4049-8161-FC129817CBE4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE39FD00-745B-4049-8161-FC129817CBE4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D64C1577-4929-4B60-939E-96DE1534891A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {F2840BC7-0188-4606-9126-DADD0F5ABF7A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {BD65D04F-08D5-40C1-8C24-77CA0BACB877} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {78040F9E-3501-4A40-82DF-00A597710F35} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {0CE86223-D31D-4315-A1F5-87BA3EE1B844} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {F1C58097-4C08-4D88-8976-6B3389391481} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {077AA5F8-8B61-420C-A6B5-0150A66FDB34} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {C5BB573D-3030-4BCB-88B7-F6A85C32766C} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {527F645C-C1FC-406E-8479-81386C8ECF13} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {E60895E5-79C4-447D-88B7-85CB5BA336A4} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {90CB5DC4-C040-45C7-8900-9688B26405BC} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {BE39FD00-745B-4049-8161-FC129817CBE4} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD} + EndGlobalSection +EndGlobal diff --git a/modules/permission-management/README.md b/modules/permission-management/README.md new file mode 100644 index 0000000..03bb586 --- /dev/null +++ b/modules/permission-management/README.md @@ -0,0 +1 @@ +# Permission Management diff --git a/modules/permission-management/common.props b/modules/permission-management/common.props new file mode 100644 index 0000000..3966a3c --- /dev/null +++ b/modules/permission-management/common.props @@ -0,0 +1,20 @@ + + + + + + Passingwind.Abp.PermissionManagement + an abp module that provider dynamic permission management service + abp, abp-module + 1.2.0 + 1.2.0 + + + + + True + \ + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionCreateDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionCreateDto.cs new file mode 100644 index 0000000..71e86bf --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionCreateDto.cs @@ -0,0 +1,13 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinitionCreateDto : DynamicPermissionDefinitionUpdateDto +{ + [Required] + [MaxLength(64)] + public virtual string Name { get; set; } = null!; + public virtual Guid GroupId { get; set; } + public virtual Guid? ParentId { get; set; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionDto.cs new file mode 100644 index 0000000..22b6794 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionDto.cs @@ -0,0 +1,15 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinitionDto : AuditedEntityDto +{ + public virtual string Name { get; set; } = null!; + public virtual string DisplayName { get; set; } = null!; + public virtual bool IsEnabled { get; set; } + public virtual Guid? GroupId { get; set; } + public virtual Guid? ParentId { get; set; } + public virtual string? Description { get; set; } + // public virtual IEnumerable PermissionLinks { get; set; } = null!; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionListRequestDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionListRequestDto.cs new file mode 100644 index 0000000..124deaa --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionListRequestDto.cs @@ -0,0 +1,9 @@ +using System; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinitionListRequestDto +{ + public Guid? GroupId { get; set; } + public Guid? ParentId { get; set; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionPagedListRequestDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionPagedListRequestDto.cs new file mode 100644 index 0000000..894e99f --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionPagedListRequestDto.cs @@ -0,0 +1,10 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinitionPagedListRequestDto : PagedResultRequestDto +{ + public Guid? GroupId { get; set; } + public Guid? ParentId { get; set; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionUpdateDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionUpdateDto.cs new file mode 100644 index 0000000..44b2864 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionDefinitionUpdateDto.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinitionUpdateDto +{ + public virtual bool IsEnabled { get; set; } + [Required] + [MaxLength(64)] + public virtual string DisplayName { get; set; } = null!; + public virtual string? Description { get; set; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionCreateOrUpdateDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionCreateOrUpdateDto.cs new file mode 100644 index 0000000..ef457e6 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionCreateOrUpdateDto.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionGroupDefinitionCreateOrUpdateDto +{ + [Required] + [MaxLength(64)] + public virtual string Name { get; set; } = null!; + [Required] + [MaxLength(64)] + public virtual string DisplayName { get; set; } = null!; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionDto.cs new file mode 100644 index 0000000..c6db34a --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionDto.cs @@ -0,0 +1,10 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionGroupDefinitionDto : AuditedEntityDto +{ + public virtual string Name { get; set; } = null!; + public virtual string DisplayName { get; set; } = null!; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionListRequestDto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionListRequestDto.cs new file mode 100644 index 0000000..181f9c0 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/DynamicPermissionGroupDefinitionListRequestDto.cs @@ -0,0 +1,7 @@ +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionGroupDefinitionListRequestDto : PagedResultRequestDto +{ +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionDefinitionAppService.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionDefinitionAppService.cs new file mode 100644 index 0000000..c00b736 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionDefinitionAppService.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionDefinitionAppService : IApplicationService +{ + Task> GetAllListAsync(DynamicPermissionDefinitionListRequestDto input); + + Task> GetListAsync(DynamicPermissionDefinitionPagedListRequestDto input); + + Task GetAsync(Guid id); + + Task CreateAsync(DynamicPermissionDefinitionCreateDto input); + + Task UpdateAsync(Guid id, DynamicPermissionDefinitionUpdateDto input); + + Task DeleteAsync(Guid id); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionGroupDefinitionAppService.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionGroupDefinitionAppService.cs new file mode 100644 index 0000000..9c72184 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/DynamicPermissions/IDynamicPermissionGroupDefinitionAppService.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionGroupDefinitionAppService : IApplicationService +{ + Task> GetAllListAsync(); + + Task> GetListAsync(DynamicPermissionGroupDefinitionListRequestDto input); + + Task GetAsync(Guid id); + + Task CreateAsync(DynamicPermissionGroupDefinitionCreateOrUpdateDto input); + + Task UpdateAsync(Guid id, DynamicPermissionGroupDefinitionCreateOrUpdateDto input); + + Task DeleteAsync(Guid id); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.abppkg new file mode 100644 index 0000000..4903279 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.application-contracts" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.csproj new file mode 100644 index 0000000..5979a24 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/Passingwind.Abp.PermissionManagement.Application.Contracts.csproj @@ -0,0 +1,16 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementApplicationContractsModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementApplicationContractsModule.cs new file mode 100644 index 0000000..977d4f9 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementApplicationContractsModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Application; +using Volo.Abp.Authorization; +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) + )] +public class PermissionManagementApplicationContractsModule : AbpModule +{ +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissionDefinitionProvider.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissionDefinitionProvider.cs new file mode 100644 index 0000000..c6a210f --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissionDefinitionProvider.cs @@ -0,0 +1,24 @@ +using Passingwind.Abp.PermissionManagement.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace Passingwind.Abp.PermissionManagement; + +public class PermissionManagementPermissionDefinitionProvider : PermissionDefinitionProvider +{ + public override void Define(IPermissionDefinitionContext context) + { + var myGroup = context.AddGroup(PermissionManagementPermissions.GroupName, L($"Permission:{PermissionManagementPermissions.GroupName}")); + + var dynamicPermissions = myGroup.AddPermission(PermissionManagementPermissions.DynamicPermissions.Default, L($"Permission:{PermissionManagementPermissions.DynamicPermissions.Default}")); + dynamicPermissions.AddChild(PermissionManagementPermissions.DynamicPermissions.Manage, L($"Permission:{PermissionManagementPermissions.DynamicPermissions.Manage}")); + + var permissions = myGroup.AddPermission(PermissionManagementPermissions.Permissions.Default, L($"Permission:{PermissionManagementPermissions.Permissions.Default}")); + permissions.AddChild(PermissionManagementPermissions.Permissions.Manage, L($"Permission:{PermissionManagementPermissions.Permissions.Manage}")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissions.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissions.cs new file mode 100644 index 0000000..4486857 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementPermissions.cs @@ -0,0 +1,25 @@ +using Volo.Abp.Reflection; + +namespace Passingwind.Abp.PermissionManagement; + +public class PermissionManagementPermissions +{ + public const string GroupName = "PermissionManagement"; + + public static class Permissions + { + public const string Default = GroupName + ".Permissions"; + public const string Manage = Default + ".Manage"; + } + + public static class DynamicPermissions + { + public const string Default = GroupName + ".DynamicPermissions"; + public const string Manage = Default + ".Manage"; + } + + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(PermissionManagementPermissions)); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementRemoteServiceConsts.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementRemoteServiceConsts.cs new file mode 100644 index 0000000..944d7ad --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application.Contracts/PermissionManagementRemoteServiceConsts.cs @@ -0,0 +1,8 @@ +namespace Passingwind.Abp.PermissionManagement; + +public static class PermissionManagementRemoteServiceConsts +{ + public const string RemoteServiceName = "PermissionManagement"; + + public const string ModuleName = "permissionManagement"; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionDefinitionAppService.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionDefinitionAppService.cs new file mode 100644 index 0000000..26de0e1 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionDefinitionAppService.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +[Authorize(PermissionManagementPermissions.DynamicPermissions.Default)] +public class DynamicPermissionDefinitionAppService : PermissionManagementAppService, IDynamicPermissionDefinitionAppService +{ + protected IDynamicPermissionDefinitionRepository PermissionDefinitionRepository { get; } + protected DynamicPermissionManager DynamicPermissionManager { get; } + + public DynamicPermissionDefinitionAppService(IDynamicPermissionDefinitionRepository permissionDefinitionRepository, DynamicPermissionManager dynamicPermissionManager) + { + PermissionDefinitionRepository = permissionDefinitionRepository; + DynamicPermissionManager = dynamicPermissionManager; + } + + public virtual async Task> GetAllListAsync(DynamicPermissionDefinitionListRequestDto input) + { + var list = await PermissionDefinitionRepository.GetListAsync(groupId: input.GroupId, parentId: input.ParentId); + + return new ListResultDto() + { + Items = ObjectMapper.Map, List>(list), + }; + } + + public virtual async Task> GetListAsync(DynamicPermissionDefinitionPagedListRequestDto input) + { + var count = await PermissionDefinitionRepository.GetCountAsync(groupId: input.GroupId, parentId: input.ParentId); + var list = await PermissionDefinitionRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, groupId: input.GroupId, parentId: input.ParentId); + + return new PagedResultDto() + { + Items = ObjectMapper.Map, List>(list), + TotalCount = count, + }; + } + + public virtual async Task GetAsync(Guid id) + { + var entity = await PermissionDefinitionRepository.GetAsync(id); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task CreateAsync(DynamicPermissionDefinitionCreateDto input) + { + var targetName = await DynamicPermissionManager.NormalizeNameAsync(input.Name); + var entity = new DynamicPermissionDefinition( + GuidGenerator.Create(), + input.Name, + targetName, + input.DisplayName, + input.IsEnabled, + input.GroupId, + input.ParentId) + { + Description = input.Description, + }; + + if (await PermissionDefinitionRepository.IsNameExistsAsync(input.Name)) + { + throw new BusinessException(PermissionManagementErrorCodes.PermissionNameExists).WithData("name", input.Name); + } + + await PermissionDefinitionRepository.InsertAsync(entity); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task UpdateAsync(Guid id, DynamicPermissionDefinitionUpdateDto input) + { + var entity = await PermissionDefinitionRepository.GetAsync(id); + + entity.IsEnabled = input.IsEnabled; + entity.DisplayName = input.DisplayName; + entity.Description = input.Description; + + await PermissionDefinitionRepository.UpdateAsync(entity); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task DeleteAsync(Guid id) + { + await PermissionDefinitionRepository.DeleteAsync(id); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionGroupDefinitionAppService.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionGroupDefinitionAppService.cs new file mode 100644 index 0000000..ee002d5 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/DynamicPermissions/DynamicPermissionGroupDefinitionAppService.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +[Authorize(PermissionManagementPermissions.DynamicPermissions.Default)] +public class DynamicPermissionGroupDefinitionAppService : PermissionManagementAppService, IDynamicPermissionGroupDefinitionAppService +{ + protected IDynamicPermissionGroupDefinitionRepository PermissionGroupDefinitionRepository { get; } + protected IDynamicPermissionDefinitionRepository DynamicPermissionDefinitionRepository { get; } + protected DynamicPermissionManager DynamicPermissionManager { get; } + + public DynamicPermissionGroupDefinitionAppService(IDynamicPermissionGroupDefinitionRepository permissionGroupDefinitionRepository, IDynamicPermissionDefinitionRepository dynamicPermissionDefinitionRepository, DynamicPermissionManager dynamicPermissionManager) + { + PermissionGroupDefinitionRepository = permissionGroupDefinitionRepository; + DynamicPermissionDefinitionRepository = dynamicPermissionDefinitionRepository; + DynamicPermissionManager = dynamicPermissionManager; + } + + public virtual async Task> GetAllListAsync() + { + var list = await PermissionGroupDefinitionRepository.GetListAsync(); + + return new PagedResultDto() + { + Items = ObjectMapper.Map, List>(list), + }; + } + + public virtual async Task> GetListAsync(DynamicPermissionGroupDefinitionListRequestDto input) + { + var count = await PermissionGroupDefinitionRepository.GetCountAsync(); + var list = await PermissionGroupDefinitionRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, sorting: nameof(DynamicPermissionGroupDefinition.Name)); + + return new PagedResultDto() + { + Items = ObjectMapper.Map, List>(list), + TotalCount = count, + }; + } + + public virtual async Task GetAsync(Guid id) + { + var entity = await PermissionGroupDefinitionRepository.GetAsync(id); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task CreateAsync(DynamicPermissionGroupDefinitionCreateOrUpdateDto input) + { + var targetName = await DynamicPermissionManager.NormalizeNameAsync(input.Name); + var entity = new DynamicPermissionGroupDefinition(GuidGenerator.Create(), input.Name, targetName, input.DisplayName); + + if (await PermissionGroupDefinitionRepository.IsNameExistsAsync(input.Name)) + { + throw new BusinessException(PermissionManagementErrorCodes.PermissionGroupNameExists).WithData("name", input.Name); + } + + await PermissionGroupDefinitionRepository.InsertAsync(entity); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task UpdateAsync(Guid id, DynamicPermissionGroupDefinitionCreateOrUpdateDto input) + { + var entity = await PermissionGroupDefinitionRepository.GetAsync(id); + + if (await PermissionGroupDefinitionRepository.IsNameExistsAsync(input.Name, new Guid[] { entity.Id })) + { + throw new BusinessException(PermissionManagementErrorCodes.PermissionGroupNameExists).WithData("name", input.Name); + } + + var targetName = await DynamicPermissionManager.NormalizeNameAsync(input.Name); + + entity.DisplayName = input.DisplayName; + entity.SetName(input.Name, targetName); + + await PermissionGroupDefinitionRepository.UpdateAsync(entity); + + return ObjectMapper.Map(entity); + } + + [Authorize(PermissionManagementPermissions.DynamicPermissions.Manage)] + public virtual async Task DeleteAsync(Guid id) + { + var count = await DynamicPermissionDefinitionRepository.GetCountAsync(groupId: id); + if (count > 0) + { + throw new BusinessException(PermissionManagementErrorCodes.PermissionGroupHasPermissions); + } + + await PermissionGroupDefinitionRepository.DeleteAsync(id); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.abppkg new file mode 100644 index 0000000..412567a --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.application" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.csproj new file mode 100644 index 0000000..cf01942 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/Passingwind.Abp.PermissionManagement.Application.csproj @@ -0,0 +1,17 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementAppService.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementAppService.cs new file mode 100644 index 0000000..d1fc618 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementAppService.cs @@ -0,0 +1,13 @@ +using Passingwind.Abp.PermissionManagement.Localization; +using Volo.Abp.Application.Services; + +namespace Passingwind.Abp.PermissionManagement; + +public abstract class PermissionManagementAppService : ApplicationService +{ + protected PermissionManagementAppService() + { + LocalizationResource = typeof(PermissionManagementResource); + ObjectMapperContext = typeof(PermissionManagementApplicationModule); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationAutoMapperProfile.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationAutoMapperProfile.cs new file mode 100644 index 0000000..126700b --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationAutoMapperProfile.cs @@ -0,0 +1,13 @@ +using AutoMapper; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; + +namespace Passingwind.Abp.PermissionManagement; + +public class PermissionManagementApplicationAutoMapperProfile : Profile +{ + public PermissionManagementApplicationAutoMapperProfile() + { + CreateMap(); + CreateMap(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationModule.cs new file mode 100644 index 0000000..544f363 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Application/PermissionManagementApplicationModule.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementDomainModule), + typeof(PermissionManagementApplicationContractsModule), + typeof(AbpAutoMapperModule), + typeof(AbpPermissionManagementApplicationModule) + )] +public class PermissionManagementApplicationModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => options.AddMaps(validate: true)); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/en.json b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/en.json new file mode 100644 index 0000000..976d911 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/en.json @@ -0,0 +1,14 @@ +{ + "culture": "en", + "texts": { + "PermissionManagement:Error:PermissionGroupNameExists": "The permission group definition name '{name}' already exists.", + "PermissionManagement:Error:PermissionGroupHasPermissions": "The permission group definition has associate defintion records.", + "PermissionManagement:Error:PermissionNameExists": "The permission definition name '{name}' already exists.", + + "Permission:PermissionManagement": "Permission management", + "Permission:PermissionManagement.DynamicPermissions": "Dynamic Permission definitions", + "Permission:PermissionManagement.DynamicPermissions.Manage": "Manage", + "Permission:PermissionManagement.Permissions": "Permissions", + "Permission:PermissionManagement.Permissions.Manage": "Manage" + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/zh-Hans.json b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/zh-Hans.json new file mode 100644 index 0000000..e84886c --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagement/zh-Hans.json @@ -0,0 +1,14 @@ +{ + "culture": "zh-Hans", + "texts": { + "PermissionManagement:Error:PermissionGroupNameExists": "权限组定义名称“{name}”已存在。", + "PermissionManagement:Error:PermissionGroupHasPermissions": "权限组定义下有其他权限定义。", + "PermissionManagement:Error:PermissionNameExists": "权限定义名称“{name}”已存在。", + + "Permission:PermissionManagement": "权限管理", + "Permission:PermissionManagement.DynamicPermissions": "动态权限定义", + "Permission:PermissionManagement.DynamicPermissions.Manage": "管理", + "Permission:PermissionManagement.Permissions": "权限", + "Permission:PermissionManagement.Permissions.Manage": "管理" + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagementResource.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagementResource.cs new file mode 100644 index 0000000..4e52d72 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Localization/PermissionManagementResource.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Localization; + +namespace Passingwind.Abp.PermissionManagement.Localization; + +[LocalizationResourceName("PermissionManagement")] +public class PermissionManagementResource +{ +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.abppkg new file mode 100644 index 0000000..8b3de05 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.domain-shared" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.csproj new file mode 100644 index 0000000..1ed6380 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/Passingwind.Abp.PermissionManagement.Domain.Shared.csproj @@ -0,0 +1,25 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + true + + + + + + + + + + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementDomainSharedModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementDomainSharedModule.cs new file mode 100644 index 0000000..5873071 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementDomainSharedModule.cs @@ -0,0 +1,30 @@ +using Passingwind.Abp.PermissionManagement.Localization; +using Volo.Abp.Domain; +using Volo.Abp.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Modularity; +using Volo.Abp.Validation; +using Volo.Abp.VirtualFileSystem; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(AbpValidationModule), + typeof(AbpDddDomainSharedModule) +)] +public class PermissionManagementDomainSharedModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => options.FileSets.AddEmbedded()); + + Configure(options => + { + options.Resources + .Add("en") + .AddVirtualJson("/Localization/PermissionManagement"); + }); + + Configure(options => options.MapCodeNamespace("PermissionManagement", typeof(PermissionManagementResource))); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementErrorCodes.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementErrorCodes.cs new file mode 100644 index 0000000..0800218 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain.Shared/PermissionManagementErrorCodes.cs @@ -0,0 +1,8 @@ +namespace Passingwind.Abp.PermissionManagement; + +public static class PermissionManagementErrorCodes +{ + public const string PermissionGroupNameExists = "PermissionManagement:Error:PermissionGroupNameExists"; + public const string PermissionGroupHasPermissions = "PermissionManagement:Error:PermissionGroupHasPermissions"; + public const string PermissionNameExists = "PermissionManagement:Error:PermissionNameExists"; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/AbpPermissionManager.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/AbpPermissionManager.cs new file mode 100644 index 0000000..f7ade42 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/AbpPermissionManager.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement; + +public class AbpPermissionManager : IAbpPermissionManager, IScopedDependency +{ + private readonly IRepository _permissionGroupRepository; + private readonly IRepository _permissionRepository; + private readonly IDistributedCache _distributedCache; + private readonly AbpDistributedCacheOptions _cacheOptions; + + public AbpPermissionManager( + IRepository permissionGroupRepository, + IRepository permissionRepository, + IDistributedCache distributedCache, + IOptions cacheOptions) + { + _permissionGroupRepository = permissionGroupRepository; + _permissionRepository = permissionRepository; + _distributedCache = distributedCache; + _cacheOptions = cacheOptions.Value; + } + + #region Copy from ABP source + + private string GetCommonStampCacheKey() + { + return $"{_cacheOptions.KeyPrefix}_AbpInMemoryPermissionCacheStamp"; + } + + protected virtual async Task ClearPermissionDefinitionCacheAsync() + { + var cacheKey = GetCommonStampCacheKey(); + await _distributedCache.RemoveAsync(cacheKey); + } + + #endregion Copy from ABP source + + public virtual async Task ClearCacheAsync(CancellationToken cancellationToken = default) + { + await ClearPermissionDefinitionCacheAsync(); + } + + public virtual async Task CreateGroupAsync(PermissionGroupDefinitionRecord record, CancellationToken cancellationToken = default) + { + return await _permissionGroupRepository.InsertAsync(record, cancellationToken: cancellationToken); + } + + public virtual async Task CreateItemAsync(PermissionDefinitionRecord record, CancellationToken cancellationToken = default) + { + return await _permissionRepository.InsertAsync(record, cancellationToken: cancellationToken); + } + + public virtual async Task DeleteGroupsAsync(IEnumerable names, CancellationToken cancellationToken = default) + { + await _permissionGroupRepository.DeleteDirectAsync(x => names.Contains(x.Name), cancellationToken); + } + + public virtual async Task DeleteItemsAsync(IEnumerable names, CancellationToken cancellationToken = default) + { + await _permissionRepository.DeleteDirectAsync(x => names.Contains(x.Name), cancellationToken); + } + + public virtual async Task FindGroupAsync(Expression> predicate, CancellationToken cancellationToken = default) + { + return await _permissionGroupRepository.FindAsync(predicate, cancellationToken: cancellationToken); + } + + public virtual async Task FindItemAsync(Expression> predicate, CancellationToken cancellationToken = default) + { + return await _permissionRepository.FindAsync(predicate, cancellationToken: cancellationToken); + } + + public virtual async Task> GetGroupsAsync(CancellationToken cancellationToken = default) + { + return await _permissionGroupRepository.GetListAsync(cancellationToken: cancellationToken); + } + + public virtual async Task> GetGroupsAsync(Expression> predicate, CancellationToken cancellationToken = default) + { + return await _permissionGroupRepository.GetListAsync(predicate, cancellationToken: cancellationToken); + } + + public virtual async Task> GetItemsAsync(CancellationToken cancellationToken = default) + { + return await _permissionRepository.GetListAsync(cancellationToken: cancellationToken); + } + + public virtual async Task> GetItemsAsync(Expression> predicate, CancellationToken cancellationToken = default) + { + return await _permissionRepository.GetListAsync(predicate, cancellationToken: cancellationToken); + } + + public virtual async Task UpdateGroupAsync(PermissionGroupDefinitionRecord record, CancellationToken cancellationToken = default) + { + return await _permissionGroupRepository.UpdateAsync(record, cancellationToken: cancellationToken); + } + + public virtual async Task UpdateItemAsync(PermissionDefinitionRecord record, CancellationToken cancellationToken = default) + { + return await _permissionRepository.UpdateAsync(record, cancellationToken: cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionDefinition.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionDefinition.cs new file mode 100644 index 0000000..cee4429 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionDefinition.cs @@ -0,0 +1,34 @@ +using System; +using JetBrains.Annotations; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionDefinition : AuditedAggregateRoot +{ + [NotNull] + public virtual string Name { get; protected set; } = null!; + [NotNull] + public virtual string TargetName { get; protected set; } = null!; + [NotNull] + public virtual string DisplayName { get; set; } = null!; + + public virtual Guid GroupId { get; protected set; } + public virtual bool IsEnabled { get; set; } + public virtual Guid? ParentId { get; protected set; } + public virtual string? Description { get; set; } + + protected DynamicPermissionDefinition() + { + } + + public DynamicPermissionDefinition(Guid id, string name, string targetName, string displayName, bool isEnabled = true, Guid groupId = default, Guid? parentId = null) : base(id) + { + Name = name; + TargetName = targetName; + DisplayName = displayName; + IsEnabled = isEnabled; + GroupId = groupId; + ParentId = parentId; + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionGroupDefinition.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionGroupDefinition.cs new file mode 100644 index 0000000..287466b --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionGroupDefinition.cs @@ -0,0 +1,47 @@ +using System; +using JetBrains.Annotations; +using Passingwind.Abp.PermissionManagement.Eto; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionGroupDefinition : AuditedAggregateRoot +{ + [NotNull] + public virtual string Name { get; protected set; } = null!; + [NotNull] + public virtual string TargetName { get; protected set; } = null!; + [NotNull] + public virtual string DisplayName { get; set; } = null!; + + protected DynamicPermissionGroupDefinition() + { + } + + public DynamicPermissionGroupDefinition(Guid id, string name, string targetName, string displayName) : base(id) + { + Name = name; + TargetName = targetName; + DisplayName = displayName; + } + + public void SetName(string name, string targetName) + { + if (name == Name) + return; + + string oldName = Name; + Name = name; + + var oldTargetName = TargetName; + TargetName = targetName; + + AddDistributedEvent(new DynamicPermissionGroupDefinitionNameChangedEto( + id: Id, + oldName: oldName, + name: Name, + oldTargetName: oldTargetName, + targetName: targetName, + displayName: DisplayName)); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLink.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLink.cs new file mode 100644 index 0000000..908ab9b --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLink.cs @@ -0,0 +1,20 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionLink : AuditedEntity +{ + public string SourceName { get; set; } = null!; + public string TargetName { get; set; } = null!; + + protected DynamicPermissionLink() + { + } + + public DynamicPermissionLink(Guid id, string sourceName, string targetName) : base(id) + { + SourceName = sourceName; + TargetName = targetName; + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLinkManager.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLinkManager.cs new file mode 100644 index 0000000..1e5e12a --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionLinkManager.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Services; +using Volo.Abp.Uow; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionLinkManager : DomainService, IDynamicPermissionLinkManager +{ + protected IDynamicPermissionLinkRepository DynamicPermissionLinkRepository { get; } + + public DynamicPermissionLinkManager(IDynamicPermissionLinkRepository dynamicPermissionLinkRepository) + { + DynamicPermissionLinkRepository = dynamicPermissionLinkRepository; + } + + [UnitOfWork] + public virtual async Task AddOrUpdateAsync(string dynamicPermissionName, IEnumerable targetNames, CancellationToken cancellationToken = default) + { + targetNames = targetNames.Distinct(); + + var list = await DynamicPermissionLinkRepository.GetListAsync(x => x.SourceName == dynamicPermissionName, cancellationToken: cancellationToken); + + var oldNames = list.Select(x => x.TargetName).ToArray(); + + var removeNames = oldNames.Except(targetNames); + + await DynamicPermissionLinkRepository.DeleteDirectAsync(x => x.SourceName == dynamicPermissionName && removeNames.Contains(x.TargetName), cancellationToken); + + var addNames = targetNames.Except(oldNames); + + await DynamicPermissionLinkRepository.InsertManyAsync(addNames.Select(x => new DynamicPermissionLink(GuidGenerator.Create(), dynamicPermissionName, x)), cancellationToken: cancellationToken); + } + + [UnitOfWork] + public virtual async Task DeleteAsync(string dynamicPermissionName, CancellationToken cancellationToken = default) + { + await DynamicPermissionLinkRepository.DeleteDirectAsync(x => x.SourceName == dynamicPermissionName, cancellationToken); + } + + [UnitOfWork] + public virtual async Task> GetLinksAsync(string dynamicPermissionName, CancellationToken cancellationToken = default) + { + var list = await DynamicPermissionLinkRepository.GetListAsync(x => x.SourceName == dynamicPermissionName, cancellationToken: cancellationToken); + + return list.ConvertAll(x => x.TargetName); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionManager.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionManager.cs new file mode 100644 index 0000000..444e7fa --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/DynamicPermissionManager.cs @@ -0,0 +1,252 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Passingwind.Abp.PermissionManagement.Options; +using Volo.Abp.Domain.Services; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public class DynamicPermissionManager : DomainService +{ + private readonly IDynamicPermissionGroupDefinitionRepository _dynamicPermissionGroupDefinitionRepository; + private readonly IDynamicPermissionDefinitionRepository _dynamicPermissionDefinitionRepository; + private readonly DynamicPermissionOptions _dynamicPermissionOptions; + + private readonly IAbpPermissionManager _abpPermissionManager; + + public DynamicPermissionManager( + IDynamicPermissionGroupDefinitionRepository dynamicPermissionGroupDefinitionRepository, + IDynamicPermissionDefinitionRepository dynamicPermissionDefinitionRepository, + IOptions dynamicPermissionOptions, + IAbpPermissionManager abpPermissionManager) + { + _dynamicPermissionGroupDefinitionRepository = dynamicPermissionGroupDefinitionRepository; + _dynamicPermissionDefinitionRepository = dynamicPermissionDefinitionRepository; + _dynamicPermissionOptions = dynamicPermissionOptions.Value; + _abpPermissionManager = abpPermissionManager; + } + + public virtual async Task InitialPermissionGroupDefinitionsAsync(CancellationToken cancellationToken = default) + { + // dynamic group + var sourceGroups = await _dynamicPermissionGroupDefinitionRepository.GetListAsync(cancellationToken: cancellationToken); + // db groups + var targetGroups = await _abpPermissionManager.GetGroupsAsync(cancellationToken: cancellationToken); + + var sourceGroupNames = sourceGroups.Select(x => x.TargetName).ToArray(); + var targetGroupNames = targetGroups.Select(x => x.Name).ToArray(); + + foreach (var group in sourceGroups) + { + if (targetGroupNames.Any(x => group.TargetName == x)) + continue; + + await CreateOrUpdatePermissionGroupDefinitionAsync(group.TargetName, group.DisplayName, cancellationToken); + } + } + + public virtual async Task InitialPermissionItemDefinitionsAsync(CancellationToken cancellationToken = default) + { + // dynamic groups + var sourceGroups = await _dynamicPermissionGroupDefinitionRepository.GetListAsync(cancellationToken: cancellationToken); + + // dynamic items + var sources = await _dynamicPermissionDefinitionRepository.GetListAsync(cancellationToken: cancellationToken); + // db items + var targets = await _abpPermissionManager.GetItemsAsync(cancellationToken: cancellationToken); + + var sourceNames = sources.Select(x => x.TargetName).ToArray(); + var targetNames = targets.Select(x => x.Name).ToArray(); + + foreach (var source in sources) + { + if (targets.Any(x => x.Name == source.TargetName)) + continue; + + var group = sourceGroups.Find(x => x.Id == source.GroupId); + if (group == null) + { + Logger.LogWarning("The dynamic permission '{0}' group id '{1}' not found.", source.Name, source.GroupId); + continue; + } + + var groupName = group.TargetName; + + string? parentName = null; + if (source.ParentId.HasValue) + { + var parent = sources.Find(x => x.Id == source.ParentId); + if (parent != null) + parentName = parent.TargetName; + } + + if (!targets.Any(x => x.Name == source.TargetName && x.GroupName == groupName)) + { + await CreateOrUpdatePermissionDefinitionAsync(source.TargetName, source.DisplayName, groupName, parentName, source.IsEnabled, cancellationToken); + } + } + } + + public virtual Task NormalizeNameAsync(string name, CancellationToken cancellationToken = default) + { + return Task.FromResult(_dynamicPermissionOptions.PermissionNamePrefix + name); + } + + public virtual async Task ChangePermissionGroupDefinitionNameAsync( + string oldName, + string newName, + string displayName, + CancellationToken cancellationToken = default) + { + if (string.IsNullOrEmpty(oldName)) + { + throw new System.ArgumentException($"'{nameof(oldName)}' cannot be null or empty.", nameof(oldName)); + } + + if (string.IsNullOrEmpty(newName)) + { + throw new System.ArgumentException($"'{nameof(newName)}' cannot be null or empty.", nameof(newName)); + } + + if (string.IsNullOrEmpty(displayName)) + { + throw new System.ArgumentException($"'{nameof(displayName)}' cannot be null or empty.", nameof(displayName)); + } + + // 1. update group + var groups = await _abpPermissionManager.GetGroupsAsync(x => x.Name == oldName, cancellationToken: cancellationToken); + + foreach (var group in groups) + { + group.Name = newName; + group.DisplayName = displayName; + + await _abpPermissionManager.UpdateGroupAsync(group, cancellationToken: cancellationToken); + } + + // 2. update definition + var records = await _abpPermissionManager.GetItemsAsync(x => x.GroupName == oldName, cancellationToken: cancellationToken); + + foreach (var item in records) + { + item.GroupName = newName; + + await _abpPermissionManager.UpdateItemAsync(item, cancellationToken: cancellationToken); + } + } + + public virtual async Task CreateOrUpdatePermissionGroupDefinitionAsync(string name, string displayName, CancellationToken cancellationToken = default) + { + if (string.IsNullOrEmpty(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or empty.", nameof(name)); + } + + if (string.IsNullOrEmpty(displayName)) + { + throw new System.ArgumentException($"'{nameof(displayName)}' cannot be null or empty.", nameof(displayName)); + } + + var group = await _abpPermissionManager.FindGroupAsync(x => x.Name == name, cancellationToken: cancellationToken); + if (group == null) + { + return await _abpPermissionManager.CreateGroupAsync(new PermissionGroupDefinitionRecord(GuidGenerator.Create(), name, displayName), cancellationToken: cancellationToken); + } + else if (group.DisplayName != displayName) + { + group.DisplayName = displayName; + return await _abpPermissionManager.UpdateGroupAsync(group, cancellationToken: cancellationToken); + } + + return group; + } + + public virtual async Task CreateOrUpdatePermissionDefinitionAsync(string name, string displayName, string groupName, string? parentName = null, bool isEnabled = true, CancellationToken cancellationToken = default) + { + if (string.IsNullOrEmpty(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or empty.", nameof(name)); + } + + if (string.IsNullOrEmpty(displayName)) + { + throw new System.ArgumentException($"'{nameof(displayName)}' cannot be null or empty.", nameof(displayName)); + } + + if (string.IsNullOrEmpty(groupName)) + { + throw new System.ArgumentException($"'{nameof(groupName)}' cannot be null or empty.", nameof(groupName)); + } + + // we do not check params 'ParentName', because 'ParentName' is not real parent. + var record = await _abpPermissionManager.FindItemAsync(x => x.Name == name && x.GroupName == groupName, cancellationToken: cancellationToken); + + if (record == null) + { + record = new PermissionDefinitionRecord( + id: GuidGenerator.Create(), + groupName: groupName, + name: name, + parentName: parentName, + displayName: displayName, + isEnabled: isEnabled); + + await _abpPermissionManager.CreateItemAsync(record, cancellationToken: cancellationToken); + } + else + { + record.DisplayName = displayName; + record.ParentName = parentName; + record.IsEnabled = isEnabled; + + await _abpPermissionManager.UpdateItemAsync(record, cancellationToken: cancellationToken); + } + + return record; + } + + public virtual async Task FindPermissionGroupDefinitionAsync(string name, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name)); + } + + return await _abpPermissionManager.FindGroupAsync(x => x.Name == name, cancellationToken: cancellationToken); + } + + public virtual async Task FindPermissionDefinitionAsync(string name, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name)); + } + + return await _abpPermissionManager.FindItemAsync(x => x.Name == name, cancellationToken: cancellationToken); + } + + public virtual async Task DeletePermissionDefinitionAsync(string name, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name)); + } + + if (_dynamicPermissionOptions.AutoCleanPermissions) + await _abpPermissionManager.DeleteItemsAsync(new string[] { name }, cancellationToken: cancellationToken); + } + + public virtual async Task DeletePermissionGroupDefinitionAsync(string name, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new System.ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name)); + } + + if (_dynamicPermissionOptions.AutoCleanPermissions) + await _abpPermissionManager.DeleteGroupsAsync(new string[] { name }, cancellationToken: cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionDefinitionRepository.cs new file mode 100644 index 0000000..76337b9 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionDefinitionRepository.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionDefinitionRepository : IRepository +{ + Task GetCountAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, CancellationToken cancellationToken = default); + + Task> GetListAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, bool includeDetails = false, CancellationToken cancellationToken = default); + + Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter = null, Guid? groupId = null, Guid? parentId = null, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default); + + Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionGroupDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionGroupDefinitionRepository.cs new file mode 100644 index 0000000..b8ea438 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionGroupDefinitionRepository.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionGroupDefinitionRepository : IRepository +{ + Task GetCountAsync(string? filter, CancellationToken cancellationToken = default); + + Task> GetListAsync(string? filter, bool includeDetails = false, CancellationToken cancellationToken = default); + + Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default); + + Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkManager.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkManager.cs new file mode 100644 index 0000000..f55af7b --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkManager.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionLinkManager +{ + Task AddOrUpdateAsync(string dynamicPermissionName, IEnumerable targetNames, CancellationToken cancellationToken = default); + Task DeleteAsync(string dynamicPermissionName, CancellationToken cancellationToken = default); + Task> GetLinksAsync(string dynamicPermissionName, CancellationToken cancellationToken = default); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkRepository.cs new file mode 100644 index 0000000..78ca5c8 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/DynamicPermissions/IDynamicPermissionLinkRepository.cs @@ -0,0 +1,8 @@ +using System; +using Volo.Abp.Domain.Repositories; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +public interface IDynamicPermissionLinkRepository : IRepository +{ +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionDefinitionNameChangedEto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionDefinitionNameChangedEto.cs new file mode 100644 index 0000000..668fc27 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionDefinitionNameChangedEto.cs @@ -0,0 +1,21 @@ +using System; + +namespace Passingwind.Abp.PermissionManagement.Eto; + +public class DynamicPermissionDefinitionNameChangedEto +{ + public DynamicPermissionDefinitionNameChangedEto(Guid id, string oldName, string name, string oldTagetName, string tagetName) + { + Id = id; + OldName = oldName; + Name = name; + OldTagetName = oldTagetName; + TagetName = tagetName; + } + + public Guid Id { get; } + public string OldName { get; } + public string Name { get; } + public string OldTagetName { get; } + public string TagetName { get; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionGroupDefinitionNameChangedEto.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionGroupDefinitionNameChangedEto.cs new file mode 100644 index 0000000..142a6c8 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Eto/DynamicPermissionGroupDefinitionNameChangedEto.cs @@ -0,0 +1,23 @@ +using System; + +namespace Passingwind.Abp.PermissionManagement.Eto; + +public class DynamicPermissionGroupDefinitionNameChangedEto +{ + public DynamicPermissionGroupDefinitionNameChangedEto(Guid id, string oldName, string name, string oldTargetName, string targetName, string displayName) + { + Id = id; + OldName = oldName; + Name = name; + OldTargetName = oldTargetName; + TargetName = targetName; + DisplayName = displayName; + } + + public Guid Id { get; } + public string OldName { get; } + public string Name { get; } + public string OldTargetName { get; } + public string TargetName { get; } + public string DisplayName { get; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionGroupDefinitionNameChangedEventHandler.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionGroupDefinitionNameChangedEventHandler.cs new file mode 100644 index 0000000..ac39bfe --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionGroupDefinitionNameChangedEventHandler.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Passingwind.Abp.PermissionManagement.Eto; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Uow; + +namespace Passingwind.Abp.PermissionManagement.EventHandlers; + +public class DynamicPermissionGroupDefinitionNameChangedEventHandler : + IDistributedEventHandler, + // + IUnitOfWorkEnabled, + ITransientDependency +{ + private readonly DynamicPermissionManager _dynamicPermissionManager; + private readonly IAbpPermissionManager _abpPermissionManager; + + public DynamicPermissionGroupDefinitionNameChangedEventHandler(DynamicPermissionManager dynamicPermissionManager, IAbpPermissionManager abpPermissionManager) + { + _dynamicPermissionManager = dynamicPermissionManager; + _abpPermissionManager = abpPermissionManager; + } + + public virtual async Task HandleEventAsync(DynamicPermissionGroupDefinitionNameChangedEto eventData) + { + await _dynamicPermissionManager.ChangePermissionGroupDefinitionNameAsync(eventData.OldTargetName, eventData.TargetName, eventData.DisplayName); + + await _abpPermissionManager.ClearCacheAsync(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionLocalEventHander.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionLocalEventHander.cs new file mode 100644 index 0000000..89a521e --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/EventHandlers/DynamicPermissionLocalEventHander.cs @@ -0,0 +1,153 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities.Events; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; + +namespace Passingwind.Abp.PermissionManagement.EventHandlers; + +public class DynamicPermissionLocalEventHander : + ILocalEventHandler>, + ILocalEventHandler>, + ILocalEventHandler>, + // + ILocalEventHandler>, + ILocalEventHandler>, + // + IUnitOfWorkEnabled, + ITransientDependency +{ + private readonly ILogger _logger; + private readonly IDynamicPermissionGroupDefinitionRepository _permissionGroupDefinitionRepository; + private readonly IDynamicPermissionDefinitionRepository _permissionDefinitionRepository; + private readonly DynamicPermissionManager _dynamicPermissionManager; + private readonly IAbpPermissionManager _abpPermissionManager; + + public DynamicPermissionLocalEventHander( + ILogger logger, + IDynamicPermissionGroupDefinitionRepository permissionGroupDefinitionRepository, + IDynamicPermissionDefinitionRepository permissionDefinitionRepository, + DynamicPermissionManager dynamicPermissionManager, + IAbpPermissionManager abpPermissionManager) + { + _logger = logger; + _permissionGroupDefinitionRepository = permissionGroupDefinitionRepository; + _permissionDefinitionRepository = permissionDefinitionRepository; + _dynamicPermissionManager = dynamicPermissionManager; + _abpPermissionManager = abpPermissionManager; + } + + /// + /// Create permission item + /// + public virtual async Task HandleEventAsync(EntityCreatedEventData eventData) + { + var entity = eventData.Entity; + var group = await _permissionGroupDefinitionRepository.FindAsync(entity.GroupId); + + if (group == null) + { + _logger.LogWarning("The dynamic permission '{0}' group id '{1}' not found.", entity.Name, entity.GroupId); + return; + } + + DynamicPermissionDefinition? parent = null; + if (entity.ParentId.HasValue) + { + parent = await _permissionDefinitionRepository.FindAsync(entity.ParentId.Value); + if (parent == null) + { + _logger.LogWarning("The dynamic permission '{0}' parent id '{1}' not found.", entity.Name, entity.ParentId); + return; + } + } + + var groupRecord = await _dynamicPermissionManager.CreateOrUpdatePermissionGroupDefinitionAsync(group.TargetName, group.DisplayName); + + await _dynamicPermissionManager.CreateOrUpdatePermissionDefinitionAsync( + entity.TargetName, + entity.DisplayName, + groupRecord.Name, + parent?.TargetName, + entity.IsEnabled); + + await _abpPermissionManager.ClearCacheAsync(); + } + + /// + /// Delete permission item + /// + public virtual async Task HandleEventAsync(EntityDeletedEventData eventData) + { + var entity = eventData.Entity; + + await _dynamicPermissionManager.DeletePermissionDefinitionAsync(entity.TargetName); + + await _abpPermissionManager.ClearCacheAsync(); + } + + /// + /// Update permission item display name + /// + public virtual async Task HandleEventAsync(EntityUpdatedEventData eventData) + { + var entity = eventData.Entity; + var group = await _permissionGroupDefinitionRepository.FindAsync(entity.GroupId); + + DynamicPermissionDefinition? parent = null; + if (entity.ParentId.HasValue) + { + parent = await _permissionDefinitionRepository.FindAsync(entity.ParentId.Value); + if (parent == null) + { + _logger.LogWarning("The dynamic permission '{0}' parent id '{1}' not found.", entity.Name, entity.ParentId); + return; + } + } + + var record = await _dynamicPermissionManager.FindPermissionDefinitionAsync(entity.TargetName); + + // if null, maybe changed name + if (record != null) + { + await _dynamicPermissionManager.CreateOrUpdatePermissionDefinitionAsync( + entity.TargetName, + entity.DisplayName, + group.TargetName, + parent?.TargetName, + entity.IsEnabled); + + await _abpPermissionManager.ClearCacheAsync(); + } + } + + /// + /// Create permission group + /// + /// + public virtual async Task HandleEventAsync(EntityCreatedEventData eventData) + { + var entity = eventData.Entity; + + await _dynamicPermissionManager.CreateOrUpdatePermissionGroupDefinitionAsync(entity.TargetName, entity.DisplayName); + } + + /// + /// Delete permission group + /// + public virtual async Task HandleEventAsync(EntityDeletedEventData eventData) + { + var entity = eventData.Entity; + + // delete group + await _dynamicPermissionManager.DeletePermissionGroupDefinitionAsync(entity.TargetName); + + // delete items + await _permissionDefinitionRepository.DeleteDirectAsync(x => x.GroupId == entity.Id); + + // + await _abpPermissionManager.ClearCacheAsync(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/IAbpPermissionManager.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/IAbpPermissionManager.cs new file mode 100644 index 0000000..e0062ea --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/IAbpPermissionManager.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement; + +public interface IAbpPermissionManager +{ + Task> GetGroupsAsync(CancellationToken cancellationToken = default); + Task> GetGroupsAsync(Expression> predicate, CancellationToken cancellationToken = default); + Task FindGroupAsync(Expression> predicate, CancellationToken cancellationToken = default); + Task DeleteGroupsAsync(IEnumerable names, CancellationToken cancellationToken = default); + Task CreateGroupAsync(PermissionGroupDefinitionRecord record, CancellationToken cancellationToken = default); + Task UpdateGroupAsync(PermissionGroupDefinitionRecord record, CancellationToken cancellationToken = default); + + Task> GetItemsAsync(CancellationToken cancellationToken = default); + Task> GetItemsAsync(Expression> predicate, CancellationToken cancellationToken = default); + Task FindItemAsync(Expression> predicate, CancellationToken cancellationToken = default); + Task DeleteItemsAsync(IEnumerable names, CancellationToken cancellationToken = default); + Task CreateItemAsync(PermissionDefinitionRecord record, CancellationToken cancellationToken = default); + Task UpdateItemAsync(PermissionDefinitionRecord record, CancellationToken cancellationToken = default); + + Task ClearCacheAsync(CancellationToken cancellationToken = default); +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Options/DynamicPermissionOptions.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Options/DynamicPermissionOptions.cs new file mode 100644 index 0000000..7a888bd --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Options/DynamicPermissionOptions.cs @@ -0,0 +1,13 @@ +namespace Passingwind.Abp.PermissionManagement.Options; + +public class DynamicPermissionOptions +{ + /// + /// Default: 'dym:' + /// + public string PermissionNamePrefix { get; set; } = "dym:"; + /// + /// Default: true + /// + public bool AutoCleanPermissions { get; set; } = true; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.abppkg new file mode 100644 index 0000000..1d574ef --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.domain" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.csproj new file mode 100644 index 0000000..643dd8d --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/Passingwind.Abp.PermissionManagement.Domain.csproj @@ -0,0 +1,15 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDbProperties.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDbProperties.cs new file mode 100644 index 0000000..b4d2090 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDbProperties.cs @@ -0,0 +1,10 @@ +namespace Passingwind.Abp.PermissionManagement; + +public static class PermissionManagementDbProperties +{ + public static string DbTablePrefix { get; set; } = "Passingwind"; + + public static string? DbSchema { get; set; } + + public const string ConnectionStringName = "PermissionManagement"; +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDomainModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDomainModule.cs new file mode 100644 index 0000000..7a160cd --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Domain/PermissionManagementDomainModule.cs @@ -0,0 +1,16 @@ +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(AbpPermissionManagementDomainModule), + typeof(PermissionManagementDomainSharedModule) +)] +public class PermissionManagementDomainModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => options.IsDynamicPermissionStoreEnabled = true); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/IPermissionManagementDbContextV2.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/IPermissionManagementDbContextV2.cs new file mode 100644 index 0000000..b4038fc --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/IPermissionManagementDbContextV2.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Data; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +[ConnectionStringName(PermissionManagementDbProperties.ConnectionStringName)] +public interface IPermissionManagementDbContextV2 : Volo.Abp.PermissionManagement.EntityFrameworkCore.IPermissionManagementDbContext +{ + DbSet DynamicPermissions { get; } + DbSet DynamicPermissionGroups { get; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextModelCreatingExtensions.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextModelCreatingExtensions.cs new file mode 100644 index 0000000..197a0d3 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextModelCreatingExtensions.cs @@ -0,0 +1,44 @@ +using Microsoft.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp; +using Volo.Abp.EntityFrameworkCore.Modeling; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +public static class PermissionManagementDbContextModelCreatingExtensions +{ + public static void ConfigurePermissionManagementV2( + this ModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + builder + .Entity(b => + { + b.ToTable(AbpPermissionManagementDbProperties.DbTablePrefix + "DynamicPermissionGroups", AbpPermissionManagementDbProperties.DbSchema); + b.ConfigureByConvention(); + + b.Property(q => q.Name).IsRequired().HasMaxLength(64); + b.Property(q => q.TargetName).IsRequired().HasMaxLength(64); + b.Property(q => q.DisplayName).IsRequired().HasMaxLength(64); + + b.HasIndex(q => q.Name).IsUnique(); + }) + .Entity(b => + { + b.ToTable(AbpPermissionManagementDbProperties.DbTablePrefix + "DynamicPermissions", AbpPermissionManagementDbProperties.DbSchema); + b.ConfigureByConvention(); + + b.Property(q => q.Name).IsRequired().HasMaxLength(64); + b.Property(q => q.TargetName).IsRequired().HasMaxLength(64); + b.Property(q => q.DisplayName).IsRequired().HasMaxLength(64); + b.Property(q => q.Description).HasMaxLength(256); + + b.HasIndex(q => q.GroupId); + b.HasIndex(q => q.Name).IsUnique(); + b.HasIndex(q => q.ParentId); + }) + ; + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextV2.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextV2.cs new file mode 100644 index 0000000..86e1f48 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementDbContextV2.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.PermissionManagement; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +[ConnectionStringName(AbpPermissionManagementDbProperties.ConnectionStringName)] +[ReplaceDbContext(typeof(Volo.Abp.PermissionManagement.EntityFrameworkCore.IPermissionManagementDbContext))] +public class PermissionManagementDbContextV2 : AbpDbContext, IPermissionManagementDbContextV2 +{ + public DbSet PermissionGroups { get; set; } + public DbSet Permissions { get; set; } + public DbSet PermissionGrants { get; set; } + + public DbSet DynamicPermissions { get; set; } + public DbSet DynamicPermissionGroups { get; set; } + + public PermissionManagementDbContextV2(DbContextOptions options) + : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigurePermissionManagementV2(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreModule.cs new file mode 100644 index 0000000..adc8fbc --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreModule.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +[DependsOn( + typeof(PermissionManagementDomainModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule) +)] +public class PermissionManagementEntityFrameworkCoreModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => options.AddDefaultRepositories()); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionDefinitionRepository.cs new file mode 100644 index 0000000..0c4f8f0 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionDefinitionRepository.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Repositories; + +public class DynamicPermissionDefinitionRepository : EfCoreRepository, IDynamicPermissionDefinitionRepository +{ + public DynamicPermissionDefinitionRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetCountAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .LongCountAsync(cancellationToken); + } + + public virtual async Task> GetListAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .ToListAsync(cancellationToken); + } + + public virtual async Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter = null, Guid? groupId = null, Guid? parentId = null, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .OrderBy(sorting ?? nameof(DynamicPermissionDefinition.Name)) + .PageBy(skipCount, maxResultCount) + .ToListAsync(cancellationToken); + } + + public virtual async Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(excludeIds?.Any() == true, x => !excludeIds!.Contains(x.Id)) + .Where(x => x.Name == name) + .AnyAsync(cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionGroupDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionGroupDefinitionRepository.cs new file mode 100644 index 0000000..bd50394 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/EntityFrameworkCore/Repositories/DynamicPermissionGroupDefinitionRepository.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Repositories; + +public class DynamicPermissionGroupDefinitionRepository : EfCoreRepository, IDynamicPermissionGroupDefinitionRepository +{ + public DynamicPermissionGroupDefinitionRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetCountAsync(string? filter, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .LongCountAsync(cancellationToken); + } + + public virtual async Task> GetListAsync(string? filter, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .ToListAsync(cancellationToken); + } + + public virtual async Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .OrderBy(sorting ?? nameof(DynamicPermissionGroupDefinition.Name)) + .PageBy(skipCount, maxResultCount) + .ToListAsync(cancellationToken); + } + + public virtual async Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(excludeIds?.Any() == true, x => !excludeIds!.Contains(x.Id)) + .Where(x => x.Name == name) + .AnyAsync(cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.abppkg new file mode 100644 index 0000000..e1c64f0 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.ef" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.csproj new file mode 100644 index 0000000..a305796 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.EntityFrameworkCore/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.csproj @@ -0,0 +1,15 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.abppkg new file mode 100644 index 0000000..7deef5e --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api-client" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.csproj new file mode 100644 index 0000000..02a4f1f --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/Passingwind.Abp.PermissionManagement.HttpApi.Client.csproj @@ -0,0 +1,20 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/PermissionManagementHttpApiClientModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/PermissionManagementHttpApiClientModule.cs new file mode 100644 index 0000000..26ca743 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi.Client/PermissionManagementHttpApiClientModule.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementApplicationContractsModule), + typeof(AbpHttpClientModule))] +public class PermissionManagementHttpApiClientModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHttpClientProxies( + typeof(PermissionManagementApplicationContractsModule).Assembly, + PermissionManagementRemoteServiceConsts.RemoteServiceName + ); + + Configure(options => options.FileSets.AddEmbedded()); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionDefinitionController.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionDefinitionController.cs new file mode 100644 index 0000000..faa3cf3 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionDefinitionController.cs @@ -0,0 +1,56 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +[Area(PermissionManagementRemoteServiceConsts.ModuleName)] +[RemoteService(Name = PermissionManagementRemoteServiceConsts.RemoteServiceName)] +[Route("api/permission-management/dynamic/definitions")] +public class DynamicPermissionDefinitionController : PermissionManagementController, IDynamicPermissionDefinitionAppService +{ + private readonly IDynamicPermissionDefinitionAppService _service; + + public DynamicPermissionDefinitionController(IDynamicPermissionDefinitionAppService service) + { + _service = service; + } + + [HttpGet] + public virtual Task> GetListAsync(DynamicPermissionDefinitionPagedListRequestDto input) + { + return _service.GetListAsync(input); + } + + [HttpGet("{id}")] + public virtual Task GetAsync(Guid id) + { + return _service.GetAsync(id); + } + + [HttpPost] + public virtual Task CreateAsync(DynamicPermissionDefinitionCreateDto input) + { + return _service.CreateAsync(input); + } + + [HttpPut("{id}")] + public virtual Task UpdateAsync(Guid id, DynamicPermissionDefinitionUpdateDto input) + { + return _service.UpdateAsync(id, input); + } + + [HttpDelete("{id}")] + public virtual Task DeleteAsync(Guid id) + { + return _service.DeleteAsync(id); + } + + [HttpGet("all")] + public virtual Task> GetAllListAsync(DynamicPermissionDefinitionListRequestDto input) + { + return _service.GetAllListAsync(input); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionGroupDefinitionController.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionGroupDefinitionController.cs new file mode 100644 index 0000000..d99b93d --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/DynamicPermissions/DynamicPermissionGroupDefinitionController.cs @@ -0,0 +1,56 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.PermissionManagement.DynamicPermissions; + +[Area(PermissionManagementRemoteServiceConsts.ModuleName)] +[RemoteService(Name = PermissionManagementRemoteServiceConsts.RemoteServiceName)] +[Route("api/permission-management/dynamic/definitions/groups")] +public class DynamicPermissionGroupDefinitionController : PermissionManagementController, IDynamicPermissionGroupDefinitionAppService +{ + private readonly IDynamicPermissionGroupDefinitionAppService _service; + + public DynamicPermissionGroupDefinitionController(IDynamicPermissionGroupDefinitionAppService service) + { + _service = service; + } + + [HttpGet] + public virtual Task> GetListAsync(DynamicPermissionGroupDefinitionListRequestDto input) + { + return _service.GetListAsync(input); + } + + [HttpGet("{id}")] + public virtual Task GetAsync(Guid id) + { + return _service.GetAsync(id); + } + + [HttpPost] + public virtual Task CreateAsync(DynamicPermissionGroupDefinitionCreateOrUpdateDto input) + { + return _service.CreateAsync(input); + } + + [HttpPut("{id}")] + public virtual Task UpdateAsync(Guid id, DynamicPermissionGroupDefinitionCreateOrUpdateDto input) + { + return _service.UpdateAsync(id, input); + } + + [HttpDelete("{id}")] + public virtual Task DeleteAsync(Guid id) + { + return _service.DeleteAsync(id); + } + + [HttpGet("all")] + public virtual Task> GetAllListAsync() + { + return _service.GetAllListAsync(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.abppkg new file mode 100644 index 0000000..515bfe6 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.http-api" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.csproj new file mode 100644 index 0000000..0ea5d58 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/Passingwind.Abp.PermissionManagement.HttpApi.csproj @@ -0,0 +1,15 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementController.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementController.cs new file mode 100644 index 0000000..4b28c9d --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementController.cs @@ -0,0 +1,12 @@ +using Passingwind.Abp.PermissionManagement.Localization; +using Volo.Abp.AspNetCore.Mvc; + +namespace Passingwind.Abp.PermissionManagement; + +public abstract class PermissionManagementController : AbpControllerBase +{ + protected PermissionManagementController() + { + LocalizationResource = typeof(PermissionManagementResource); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementHttpApiModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementHttpApiModule.cs new file mode 100644 index 0000000..2416b4e --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.HttpApi/PermissionManagementHttpApiModule.cs @@ -0,0 +1,31 @@ +using Localization.Resources.AbpUi; +using Microsoft.Extensions.DependencyInjection; +using Passingwind.Abp.PermissionManagement.Localization; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.HttpApi; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementApplicationContractsModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpAspNetCoreMvcModule))] +public class PermissionManagementHttpApiModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => mvcBuilder.AddApplicationPartIfNotExists(typeof(PermissionManagementHttpApiModule).Assembly)); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xml new file mode 100644 index 0000000..be0de3a --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xsd new file mode 100644 index 0000000..3f3946e --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/Passingwind.Abp.PermissionManagement.Installer.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/Passingwind.Abp.PermissionManagement.Installer.csproj new file mode 100644 index 0000000..35a4c60 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/Passingwind.Abp.PermissionManagement.Installer.csproj @@ -0,0 +1,23 @@ + + + + + + net8.0 + true + Passingwind.Abp.PermissionManagement + + + + + + + + + + true + content\ + + + + diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/PermissionManagementInstallerModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/PermissionManagementInstallerModule.cs new file mode 100644 index 0000000..a4b34e5 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.Installer/PermissionManagementInstallerModule.cs @@ -0,0 +1,18 @@ +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(AbpVirtualFileSystemModule) + )] +public class PermissionManagementInstallerModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xml b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xsd b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/IPermissionManagementMongoDbContextV2.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/IPermissionManagementMongoDbContextV2.cs new file mode 100644 index 0000000..bdcafbf --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/IPermissionManagementMongoDbContextV2.cs @@ -0,0 +1,13 @@ +using MongoDB.Driver; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Data; +using Volo.Abp.PermissionManagement.MongoDB; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +[ConnectionStringName(PermissionManagementDbProperties.ConnectionStringName)] +public interface IPermissionManagementMongoDbContextV2 : IPermissionManagementMongoDbContext +{ + IMongoCollection DynamicPermissions { get; } + IMongoCollection DynamicPermissionGroups { get; } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextExtensions.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextExtensions.cs new file mode 100644 index 0000000..ff8ed34 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextExtensions.cs @@ -0,0 +1,18 @@ +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp; +using Volo.Abp.MongoDB; +using Volo.Abp.PermissionManagement; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +public static class PermissionManagementMongoDbContextExtensions +{ + public static void ConfigurePermissionManagementV2( + this IMongoModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + builder.Entity(b => b.CollectionName = AbpPermissionManagementDbProperties.DbTablePrefix + "DynamicPermissionGroups"); + builder.Entity(b => b.CollectionName = AbpPermissionManagementDbProperties.DbTablePrefix + "DynamicPermissions"); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextV2.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextV2.cs new file mode 100644 index 0000000..57867ff --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbContextV2.cs @@ -0,0 +1,29 @@ +using MongoDB.Driver; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MongoDB; +using Volo.Abp.PermissionManagement; +using Volo.Abp.PermissionManagement.MongoDB; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +[ConnectionStringName(PermissionManagementDbProperties.ConnectionStringName)] +[ReplaceDbContext(typeof(IPermissionManagementMongoDbContext))] +public class PermissionManagementMongoDbContextV2 : AbpMongoDbContext, IPermissionManagementMongoDbContextV2 +{ + public IMongoCollection PermissionGroups => Collection(); + public IMongoCollection Permissions => Collection(); + public IMongoCollection PermissionGrants => Collection(); + + public IMongoCollection DynamicPermissions => Collection(); + public IMongoCollection DynamicPermissionGroups => Collection(); + + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); + + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigurePermissionManagementV2(); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbModule.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbModule.cs new file mode 100644 index 0000000..2f2acbb --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/PermissionManagementMongoDbModule.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.MongoDB; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +[DependsOn( + typeof(PermissionManagementDomainModule), + typeof(PermissionManagementDomainModule), + typeof(AbpPermissionManagementMongoDbModule) + )] +public class PermissionManagementMongoDbModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddMongoDbContext(options => options.AddDefaultRepositories()); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionDefinitionRepository.cs new file mode 100644 index 0000000..149e8c3 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionDefinitionRepository.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Domain.Repositories.MongoDB; +using Volo.Abp.MongoDB; + +namespace Passingwind.Abp.PermissionManagement.MongoDB.Repositories; + +public class DynamicPermissionDefinitionRepository : MongoDbRepository, IDynamicPermissionDefinitionRepository +{ + public DynamicPermissionDefinitionRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetCountAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .As>() + .LongCountAsync(cancellationToken); + } + + public virtual async Task> GetListAsync(string? filter = null, Guid? groupId = null, Guid? parentId = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .As>() + .ToListAsync(cancellationToken); + } + + public virtual async Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter = null, Guid? groupId = null, Guid? parentId = null, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .WhereIf(groupId.HasValue, x => x.GroupId == groupId) + .WhereIf(parentId.HasValue, x => x.ParentId == parentId) + .OrderBy(sorting ?? nameof(DynamicPermissionDefinition.Name)) + .PageBy(skipCount, maxResultCount) + .As>() + .ToListAsync(cancellationToken); + } + + public virtual async Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(excludeIds?.Any() == true, x => !excludeIds!.Contains(x.Id)) + .Where(x => x.Name == name) + .As>() + .AnyAsync(cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionGroupDefinitionRepository.cs b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionGroupDefinitionRepository.cs new file mode 100644 index 0000000..bad5bdf --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/MongoDB/Repositories/DynamicPermissionGroupDefinitionRepository.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using Passingwind.Abp.PermissionManagement.DynamicPermissions; +using Volo.Abp.Domain.Repositories.MongoDB; +using Volo.Abp.MongoDB; + +namespace Passingwind.Abp.PermissionManagement.MongoDB.Repositories; + +public class DynamicPermissionGroupDefinitionRepository : MongoDbRepository, IDynamicPermissionGroupDefinitionRepository +{ + public DynamicPermissionGroupDefinitionRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetCountAsync(string? filter, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .As>() + .LongCountAsync(cancellationToken); + } + + public virtual async Task> GetListAsync(string? filter, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .As>() + .ToListAsync(cancellationToken); + } + + public virtual async Task> GetPagedListAsync(int skipCount, int maxResultCount, string? filter, string? sorting = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(!string.IsNullOrEmpty(filter), x => x.Name.Contains(filter!) || x.DisplayName.Contains(filter!)) + .As>() + .OrderBy(sorting ?? nameof(DynamicPermissionGroupDefinition.Name)) + .PageBy(skipCount, maxResultCount) + .As>() + .ToListAsync(cancellationToken); + } + + public virtual async Task IsNameExistsAsync(string name, Guid[]? excludeIds = null, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(); + + return await query + .WhereIf(excludeIds?.Any() == true, x => !excludeIds!.Contains(x.Id)) + .Where(x => x.Name == name) + .As>() + .AnyAsync(cancellationToken); + } +} diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.abppkg b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.abppkg new file mode 100644 index 0000000..8b23fd1 --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.mongodb" +} \ No newline at end of file diff --git a/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.csproj b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.csproj new file mode 100644 index 0000000..ad6464a --- /dev/null +++ b/modules/permission-management/src/Passingwind.Abp.PermissionManagement.MongoDB/Passingwind.Abp.PermissionManagement.MongoDB.csproj @@ -0,0 +1,15 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xml b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xsd b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.abppkg new file mode 100644 index 0000000..a686451 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.csproj new file mode 100644 index 0000000..f84b529 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Passingwind.Abp.PermissionManagement.Application.Tests.csproj @@ -0,0 +1,16 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestBase.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestBase.cs new file mode 100644 index 0000000..779835d --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestBase.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +/* Inherit from this class for your application layer tests. + * See SampleAppService_Tests for example. + */ +public abstract class PermissionManagementApplicationTestBase : PermissionManagementTestBase + where TStartupModule : IAbpModule +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestModule.cs new file mode 100644 index 0000000..66a7d7f --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/PermissionManagementApplicationTestModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementApplicationModule), + typeof(PermissionManagementDomainTestModule) + )] +public class PermissionManagementApplicationTestModule : AbpModule +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Samples/SampleAppService_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Samples/SampleAppService_Tests.cs new file mode 100644 index 0000000..a37589f --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Application.Tests/Samples/SampleAppService_Tests.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Modularity; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.Samples; + +public abstract class SampleAppService_Tests : PermissionManagementApplicationTestBase + where TStartupModule : IAbpModule +{ + private readonly ISampleAppService _sampleAppService; + + protected SampleAppService_Tests() + { + _sampleAppService = GetRequiredService(); + } + + [Fact] + public async Task GetAsync() + { + var result = await _sampleAppService.GetAsync(); + result.Value.ShouldBe(42); + } + + [Fact] + public async Task GetAuthorizedAsync() + { + var result = await _sampleAppService.GetAuthorizedAsync(); + result.Value.ShouldBe(42); + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xml b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xsd b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.abppkg new file mode 100644 index 0000000..a686451 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.csproj new file mode 100644 index 0000000..6625b4f --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Passingwind.Abp.PermissionManagement.Domain.Tests.csproj @@ -0,0 +1,20 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestBase.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestBase.cs new file mode 100644 index 0000000..695e414 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestBase.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +/* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ +public abstract class PermissionManagementDomainTestBase : PermissionManagementTestBase + where TStartupModule : IAbpModule +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestModule.cs new file mode 100644 index 0000000..cf0d14b --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/PermissionManagementDomainTestModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(PermissionManagementDomainModule), + typeof(PermissionManagementTestBaseModule) +)] +public class PermissionManagementDomainTestModule : AbpModule +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Samples/SampleManager_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Samples/SampleManager_Tests.cs new file mode 100644 index 0000000..bf79e89 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.Domain.Tests/Samples/SampleManager_Tests.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using Volo.Abp.Modularity; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.Samples; + +public abstract class SampleManager_Tests : PermissionManagementDomainTestBase + where TStartupModule : IAbpModule +{ + //private readonly SampleManager _sampleManager; + + public SampleManager_Tests() + { + //_sampleManager = GetRequiredService(); + } + + [Fact] + public Task Method1Async() + { + return Task.CompletedTask; + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreSampleAppService_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreSampleAppService_Tests.cs new file mode 100644 index 0000000..3005a5e --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreSampleAppService_Tests.cs @@ -0,0 +1,9 @@ +using Passingwind.Abp.PermissionManagement.Samples; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Applications; + +public class EfCoreSampleAppService_Tests : SampleAppService_Tests +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Domains/EfCoreSampleDomain_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Domains/EfCoreSampleDomain_Tests.cs new file mode 100644 index 0000000..6cf6040 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Domains/EfCoreSampleDomain_Tests.cs @@ -0,0 +1,9 @@ +using Passingwind.Abp.PermissionManagement.Samples; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Domains; + +public class EfCoreSampleDomain_Tests : SampleManager_Tests +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestBase.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestBase.cs new file mode 100644 index 0000000..d918fd0 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestBase.cs @@ -0,0 +1,9 @@ +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +/* This class can be used as a base class for EF Core integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class PermissionManagementEntityFrameworkCoreTestBase : PermissionManagementTestBase +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestModule.cs new file mode 100644 index 0000000..7c08935 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/PermissionManagementEntityFrameworkCoreTestModule.cs @@ -0,0 +1,45 @@ +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Sqlite; +using Volo.Abp.Modularity; +using Volo.Abp.Uow; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore; + +[DependsOn( + typeof(PermissionManagementApplicationTestModule), + typeof(PermissionManagementEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) +)] +public class PermissionManagementEntityFrameworkCoreTestModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAlwaysDisableUnitOfWorkTransaction(); + + var sqliteConnection = CreateDatabaseAndGetConnection(); + + Configure(options => + { + options.Configure(abpDbContextConfigurationContext => + { + abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); + }); + }); + } + + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); + connection.Open(); + + new PermissionManagementDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + + return connection; + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs new file mode 100644 index 0000000..f084606 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs @@ -0,0 +1,11 @@ +using Passingwind.Abp.PermissionManagement.Samples; + +namespace Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Samples; + +public class SampleRepository_Tests : SampleRepository_Tests +{ + /* Don't write custom repository tests here, instead write to + * the base class. + * One exception can be some specific tests related to EF core. + */ +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xml b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xsd b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg new file mode 100644 index 0000000..a686451 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.csproj new file mode 100644 index 0000000..5377daa --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests/Passingwind.Abp.PermissionManagement.EntityFrameworkCore.Tests.csproj @@ -0,0 +1,19 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs new file mode 100644 index 0000000..bd1e57e --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -0,0 +1,153 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using IdentityModel.Client; +using Microsoft.Extensions.Configuration; +using Passingwind.Abp.PermissionManagement.Samples; +using Volo.Abp.DependencyInjection; +using Volo.Abp.IdentityModel; + +namespace Passingwind.Abp.PermissionManagement; + +public class ClientDemoService : ITransientDependency +{ + private readonly ISampleAppService _sampleAppService; + private readonly IIdentityModelAuthenticationService _authenticationService; + private readonly IConfiguration _configuration; + + public ClientDemoService( + ISampleAppService sampleAppService, + IIdentityModelAuthenticationService authenticationService, + IConfiguration configuration) + { + _sampleAppService = sampleAppService; + _authenticationService = authenticationService; + _configuration = configuration; + } + + public async Task RunAsync() + { + await TestWithDynamicProxiesAsync(); + await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); + await TestAllManuallyAsync(); + } + + /* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy + * feature. It is just simple as calling a local service method. + * Authorization and HTTP request details are handled by the ABP framework. + */ + private async Task TestWithDynamicProxiesAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); + + var result = await _sampleAppService.GetAsync(); + Console.WriteLine("Result: " + result.Value); + + result = await _sampleAppService.GetAuthorizedAsync(); + Console.WriteLine("Result (authorized): " + result.Value); + } + + /* Shows how to use HttpClient to perform a request to the HTTP API. + * It uses ABP's IIdentityModelAuthenticationService to simplify obtaining access tokens. + */ + private async Task TestWithHttpClientAndIdentityModelAuthenticationServiceAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdentityModelAuthenticationServiceAsync)} *****"); + + //Get access token using ABP's IIdentityModelAuthenticationService + + var accessToken = await _authenticationService.GetAccessTokenAsync( + new IdentityClientConfiguration( + _configuration["IdentityClients:Default:Authority"], + _configuration["IdentityClients:Default:Scope"], + _configuration["IdentityClients:Default:ClientId"], + _configuration["IdentityClients:Default:ClientSecret"], + _configuration["IdentityClients:Default:GrantType"], + _configuration["IdentityClients:Default:UserName"], + _configuration["IdentityClients:Default:UserPassword"] + ) + ); + + //Perform the actual HTTP request + + using (var httpClient = new HttpClient()) + { + httpClient.SetBearerToken(accessToken); + + var url = _configuration["RemoteServices:PermissionManagement:BaseUrl"] + + "api/PermissionManagement/sample/authorized"; + + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else + { + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); + } + } + } + + /* Shows how to use HttpClient to perform a request to the HTTP API. + */ + private async Task TestAllManuallyAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****"); + + //Obtain access token from the IDS4 server + + // discover endpoints from metadata + var client = new HttpClient(); + var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]); + if (disco.IsError) + { + Console.WriteLine(disco.Error); + return; + } + + // request token + var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest + { + Address = disco.TokenEndpoint, + ClientId = _configuration["IdentityClients:Default:ClientId"], + ClientSecret = _configuration["IdentityClients:Default:ClientSecret"], + UserName = _configuration["IdentityClients:Default:UserName"], + Password = _configuration["IdentityClients:Default:UserPassword"], + Scope = _configuration["IdentityClients:Default:Scope"] + }); + + if (tokenResponse.IsError) + { + Console.WriteLine(tokenResponse.Error); + return; + } + + Console.WriteLine(tokenResponse.Json); + + //Perform the actual HTTP request + + using (var httpClient = new HttpClient()) + { + httpClient.SetBearerToken(tokenResponse.AccessToken); + + var url = _configuration["RemoteServices:PermissionManagement:BaseUrl"] + + "api/PermissionManagement/sample/authorized"; + + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else + { + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); + } + } + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs new file mode 100644 index 0000000..b1da8a1 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.Hosting; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; + +namespace Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp; + +public class ConsoleTestAppHostedService : IHostedService +{ + private readonly IConfiguration _configuration; + + public ConsoleTestAppHostedService(IConfiguration configuration) + { + _configuration = configuration; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + using (var application = await AbpApplicationFactory.CreateAsync(options => + { + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + })) + { + await application.InitializeAsync(); + + var demo = application.ServiceProvider.GetRequiredService(); + await demo.RunAsync(); + + await application.ShutdownAsync(); + } + } + + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.abppkg new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.abppkg @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.csproj new file mode 100644 index 0000000..6642083 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp.csproj @@ -0,0 +1,27 @@ + + + + Exe + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + + + PreserveNewest + Always + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/PermissionManagementConsoleApiClientModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/PermissionManagementConsoleApiClientModule.cs new file mode 100644 index 0000000..90cd7d7 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/PermissionManagementConsoleApiClientModule.cs @@ -0,0 +1,15 @@ +using Volo.Abp.Autofac; +using Volo.Abp.Http.Client.IdentityModel; +using Volo.Abp.Modularity; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(PermissionManagementHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] +public class PermissionManagementConsoleApiClientModule : AbpModule +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Program.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Program.cs new file mode 100644 index 0000000..d782b78 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/Program.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp; + +class Program +{ + static async Task Main(string[] args) + { + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.json b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.json new file mode 100644 index 0000000..c0fee33 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.json @@ -0,0 +1,21 @@ +{ + "RemoteServices": { + "Default": { + "BaseUrl": "https://localhost:44344/" + }, + "PermissionManagement": { + "BaseUrl": "https://localhost:44371/" + } + }, + "IdentityClients": { + "Default": { + "GrantType": "password", + "ClientId": "PermissionManagement_App", + "ClientSecret": "1q2w3e*", + "UserName": "admin", + "UserPassword": "1q2w3E*", + "Authority": "https://localhost:44344/", + "Scope": "PermissionManagement" + } + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xml b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xsd b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Applications/MongoDBSampleAppService_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Applications/MongoDBSampleAppService_Tests.cs new file mode 100644 index 0000000..c8d9a67 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Applications/MongoDBSampleAppService_Tests.cs @@ -0,0 +1,11 @@ +using Passingwind.Abp.PermissionManagement.MongoDB; +using Passingwind.Abp.PermissionManagement.Samples; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.MongoDb.Applications; + +[Collection(MongoTestCollection.Name)] +public class MongoDBSampleAppService_Tests : SampleAppService_Tests +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Domains/MongoDBSampleDomain_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Domains/MongoDBSampleDomain_Tests.cs new file mode 100644 index 0000000..bd73b7c --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Domains/MongoDBSampleDomain_Tests.cs @@ -0,0 +1,10 @@ +using Passingwind.Abp.PermissionManagement.Samples; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.MongoDB.Domains; + +[Collection(MongoTestCollection.Name)] +public class MongoDBSampleDomain_Tests : SampleManager_Tests +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoDbFixture.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoDbFixture.cs new file mode 100644 index 0000000..5c03ed3 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoDbFixture.cs @@ -0,0 +1,34 @@ +using System; +using EphemeralMongo; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +public class MongoDbFixture : IDisposable +{ + public readonly static IMongoRunner MongoDbRunner; + + static MongoDbFixture() + { + MongoDbRunner = MongoRunner.Run(new MongoRunnerOptions + { + UseSingleNodeReplicaSet = true + }); + } + + public static string GetRandomConnectionString() + { + return GetConnectionString("Db_" + Guid.NewGuid().ToString("N")); + } + + public static string GetConnectionString(string databaseName) + { + var stringArray = MongoDbRunner.ConnectionString.Split('?'); + var connectionString = stringArray[0].EnsureEndsWith('/') + databaseName + "/?" + stringArray[1]; + return connectionString; + } + + public void Dispose() + { + MongoDbRunner?.Dispose(); + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoTestCollection.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoTestCollection.cs new file mode 100644 index 0000000..1941825 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/MongoTestCollection.cs @@ -0,0 +1,9 @@ +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +[CollectionDefinition(Name)] +public class MongoTestCollection : ICollectionFixture +{ + public const string Name = "MongoDB Collection"; +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestBase.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestBase.cs new file mode 100644 index 0000000..13fa6be --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestBase.cs @@ -0,0 +1,9 @@ +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +/* This class can be used as a base class for MongoDB integration tests, + * while SampleRepository_Tests uses a different approach. + */ +public abstract class PermissionManagementMongoDbTestBase : PermissionManagementTestBase +{ + +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestModule.cs new file mode 100644 index 0000000..0ef3aa7 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/PermissionManagementMongoDbTestModule.cs @@ -0,0 +1,21 @@ +using System; +using Volo.Abp.Data; +using Volo.Abp.Modularity; +using Volo.Abp.Uow; + +namespace Passingwind.Abp.PermissionManagement.MongoDB; + +[DependsOn( + typeof(PermissionManagementApplicationTestModule), + typeof(PermissionManagementMongoDbModule) +)] +public class PermissionManagementMongoDbTestModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.ConnectionStrings.Default = MongoDbFixture.GetRandomConnectionString(); + }); + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs new file mode 100644 index 0000000..c35cb04 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/MongoDB/Samples/SampleRepository_Tests.cs @@ -0,0 +1,13 @@ +using Passingwind.Abp.PermissionManagement.Samples; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.MongoDB.Samples; + +[Collection(MongoTestCollection.Name)] +public class SampleRepository_Tests : SampleRepository_Tests +{ + /* Don't write custom repository tests here, instead write to + * the base class. + * One exception can be some specific tests related to MongoDB. + */ +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.abppkg new file mode 100644 index 0000000..a686451 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.abppkg @@ -0,0 +1,3 @@ +{ + "role": "lib.test" +} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.csproj new file mode 100644 index 0000000..f3ce32a --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.MongoDB.Tests/Passingwind.Abp.PermissionManagement.MongoDB.Tests.csproj @@ -0,0 +1,20 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xml b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xml new file mode 100644 index 0000000..1715698 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xsd b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xsd new file mode 100644 index 0000000..ffa6fc4 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.abppkg b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.abppkg new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.abppkg @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.csproj b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.csproj new file mode 100644 index 0000000..6f23225 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Passingwind.Abp.PermissionManagement.TestBase.csproj @@ -0,0 +1,27 @@ + + + + + + net8.0 + Passingwind.Abp.PermissionManagement + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementDataSeedContributor.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementDataSeedContributor.cs new file mode 100644 index 0000000..894f1eb --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementDataSeedContributor.cs @@ -0,0 +1,32 @@ +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; + +namespace Passingwind.Abp.PermissionManagement; + +public class PermissionManagementDataSeedContributor : IDataSeedContributor, ITransientDependency +{ + private readonly IGuidGenerator _guidGenerator; + private readonly ICurrentTenant _currentTenant; + + public PermissionManagementDataSeedContributor( + IGuidGenerator guidGenerator, ICurrentTenant currentTenant) + { + _guidGenerator = guidGenerator; + _currentTenant = currentTenant; + } + + public Task SeedAsync(DataSeedContext context) + { + /* Instead of returning the Task.CompletedTask, you can insert your test data + * at this point! + */ + + using (_currentTenant.Change(context?.TenantId)) + { + return Task.CompletedTask; + } + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBase.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBase.cs new file mode 100644 index 0000000..d0f2492 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBase.cs @@ -0,0 +1,59 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Modularity; +using Volo.Abp.Uow; +using Volo.Abp.Testing; + +namespace Passingwind.Abp.PermissionManagement; + +/* All test classes are derived from this class, directly or indirectly. */ +public abstract class PermissionManagementTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule +{ + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) + { + options.UseAutofac(); + } + + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + await action(); + + await uow.CompleteAsync(); + } + } + } + + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + var result = await func(); + await uow.CompleteAsync(); + return result; + } + } + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBaseModule.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBaseModule.cs new file mode 100644 index 0000000..29fc972 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/PermissionManagementTestBaseModule.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Authorization; +using Volo.Abp.Autofac; +using Volo.Abp.Data; +using Volo.Abp.Guids; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace Passingwind.Abp.PermissionManagement; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(AbpGuidsModule) +)] +public class PermissionManagementTestBaseModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAlwaysAllowAuthorization(); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } + + private static void SeedTestData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => + { + using (var scope = context.ServiceProvider.CreateScope()) + { + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Samples/SampleRepository_Tests.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Samples/SampleRepository_Tests.cs new file mode 100644 index 0000000..90ad77c --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Samples/SampleRepository_Tests.cs @@ -0,0 +1,26 @@ +using System.Threading.Tasks; +using Volo.Abp.Modularity; +using Xunit; + +namespace Passingwind.Abp.PermissionManagement.Samples; + +/* Write your custom repository tests like that, in this project, as abstract classes. + * Then inherit these abstract classes from EF Core & MongoDB test projects. + * In this way, both database providers are tests with the same set tests. + */ +public abstract class SampleRepository_Tests : PermissionManagementTestBase + where TStartupModule : IAbpModule +{ + //private readonly ISampleRepository _sampleRepository; + + protected SampleRepository_Tests() + { + //_sampleRepository = GetRequiredService(); + } + + [Fact] + public Task Method1Async() + { + return Task.CompletedTask; + } +} diff --git a/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Security/FakeCurrentPrincipalAccessor.cs new file mode 100644 index 0000000..772ef00 --- /dev/null +++ b/modules/permission-management/test/Passingwind.Abp.PermissionManagement.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Security.Claims; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Security.Claims; + +namespace Passingwind.Abp.PermissionManagement.Security; + +[Dependency(ReplaceServices = true)] +public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor +{ + protected override ClaimsPrincipal GetClaimsPrincipal() + { + return GetPrincipal(); + } + + private ClaimsPrincipal GetPrincipal() + { + return new ClaimsPrincipal(new ClaimsIdentity(new List + { + new Claim(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), + new Claim(AbpClaimTypes.UserName, "admin"), + new Claim(AbpClaimTypes.Email, "admin@abp.io") + } + ) + ); + } +}