Browse Source

feat(gdpr): 增加客户端代理模块

pull/1125/head
colin 11 months ago
parent
commit
479f2bdece
  1. 22
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.Domain.Identity/LINGYUN/Abp/Gdpr/Identity/AbpGdprIdentityUserDataProvider.cs
  2. 67
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/LINGYUN/Abp/Gdpr/GdprRequestClientProxy.Generated.cs
  3. 7
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/LINGYUN/Abp/Gdpr/GdprRequestClientProxy.cs
  4. 362
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/gdpr-generate-proxy.json
  5. 3
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/FodyWeavers.xml
  6. 30
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/FodyWeavers.xsd
  7. 32
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/LINGYUN.Abp.Gdpr.HttpApi.Client.csproj
  8. 24
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/LINGYUN/Abp/Gdpr/AbpGdprHttpApiClientModule.cs

22
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.Domain.Identity/LINGYUN/Abp/Gdpr/Identity/AbpGdprIdentityUserDataProvider.cs

@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.ChangeTracking;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Gdpr;
using Volo.Abp.Identity;
using Volo.Abp.Users;
@ -21,31 +20,36 @@ public class AbpGdprIdentityUserDataProvider: GdprUserDataProviderBase
public async override Task DeleteAsync(GdprDeleteUserDataContext context)
{
var identityUserRepository = context.ServiceProvider.GetRequiredService<IIdentityUserRepository>();
var identityUserManager = context.ServiceProvider.GetRequiredService<IdentityUserManager>();
var identityUser = await identityUserManager.GetByIdAsync(context.UserId);
identityUser.Name = "";
identityUser.Surname = "";
identityUser.SetIsActive(false);
await identityUserRepository.EnsureCollectionLoadedAsync(identityUser, u => u.Claims);
identityUser.Claims.Clear();
// TODO: 应设置为空字符串, 但是abp框架不允许Email为空
(await identityUserManager.SetEmailAsync(identityUser, $"{identityUser.UserName}@abp.io")).CheckErrors();
(await identityUserManager.SetPhoneNumberAsync(identityUser, "")).CheckErrors();
// 清理身份标识
var userClaims = await identityUserManager.GetClaimsAsync(identityUser);
(await identityUserManager.RemoveClaimsAsync(identityUser, userClaims)).CheckErrors();
// TODO: 是否需要清理第三方关联账户?
//var userLogins = await identityUserManager.GetLoginsAsync(identityUser);
//foreach (var userLogin in userLogins)
//{
// (await identityUserManager.RemoveLoginAsync(identityUser, userLogin.LoginProvider, userLogin.ProviderKey)).CheckErrors();
//}
(await identityUserManager.UpdateAsync(identityUser)).CheckErrors();
}
[DisableEntityChangeTracking]
public async override Task PorepareAsync(GdprPrepareUserDataContext context)
{
var identityUserRepository = context.ServiceProvider.GetRequiredService<IIdentityUserRepository>();
var identityUser = await identityUserRepository.GetAsync(context.UserId);
var identityUserManager = context.ServiceProvider.GetRequiredService<IdentityUserManager>();
var identityUser = await identityUserManager.GetByIdAsync(context.UserId);
var gdprDataInfo = new GdprDataInfo
{

67
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/LINGYUN/Abp/Gdpr/GdprRequestClientProxy.Generated.cs

@ -0,0 +1,67 @@
// This file is automatically generated by ABP framework to use MVC Controllers from CSharp
using LINGYUN.Abp.Gdpr;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Content;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Modeling;
// ReSharper disable once CheckNamespace
namespace LINGYUN.Abp.Gdpr;
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IGdprRequestAppService), typeof(GdprRequestClientProxy))]
public partial class GdprRequestClientProxy : ClientProxyBase<IGdprRequestAppService>, IGdprRequestAppService
{
public virtual async Task DeleteAsync(Guid id)
{
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
public virtual async Task DeletePersonalAccountAsync()
{
await RequestAsync(nameof(DeletePersonalAccountAsync));
}
public virtual async Task DeletePersonalDataAsync()
{
await RequestAsync(nameof(DeletePersonalDataAsync));
}
public virtual async Task<GdprRequestDto> GetAsync(Guid id)
{
return await RequestAsync<GdprRequestDto>(nameof(GetAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
public virtual async Task<PagedResultDto<GdprRequestDto>> GetListAsync(GdprRequestGetListInput input)
{
return await RequestAsync<PagedResultDto<GdprRequestDto>>(nameof(GetListAsync), new ClientProxyRequestTypeValue
{
{ typeof(GdprRequestGetListInput), input }
});
}
public virtual async Task<IRemoteStreamContent> DownloadPersonalDataAsync(Guid requestId)
{
return await RequestAsync<IRemoteStreamContent>(nameof(DownloadPersonalDataAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), requestId }
});
}
public virtual async Task PreparePersonalDataAsync()
{
await RequestAsync(nameof(PreparePersonalDataAsync));
}
}

7
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/LINGYUN/Abp/Gdpr/GdprRequestClientProxy.cs

@ -0,0 +1,7 @@
// This file is part of GdprRequestClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace LINGYUN.Abp.Gdpr;
public partial class GdprRequestClientProxy
{
}

362
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/ClientProxies/gdpr-generate-proxy.json

@ -0,0 +1,362 @@
{
"modules": {
"gdpr": {
"rootPath": "gdpr",
"remoteServiceName": "Gdpr",
"controllers": {
"LINGYUN.Abp.Gdpr.GdprRequestController": {
"controllerName": "GdprRequest",
"controllerGroupName": "GdprRequest",
"isRemoteService": true,
"isIntegrationService": false,
"apiVersion": null,
"type": "LINGYUN.Abp.Gdpr.GdprRequestController",
"interfaces": [
{
"type": "LINGYUN.Abp.Gdpr.IGdprRequestAppService",
"name": "IGdprRequestAppService",
"methods": [
{
"name": "GetAsync",
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"returnValue": {
"type": "LINGYUN.Abp.Gdpr.GdprRequestDto",
"typeSimple": "LINGYUN.Abp.Gdpr.GdprRequestDto"
}
},
{
"name": "GetListAsync",
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput, LINGYUN.Abp.Gdpr.Application.Contracts",
"type": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput",
"typeSimple": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput",
"isOptional": false,
"defaultValue": null
}
],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.PagedResultDto<LINGYUN.Abp.Gdpr.GdprRequestDto>",
"typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto<LINGYUN.Abp.Gdpr.GdprRequestDto>"
}
},
{
"name": "DownloadPersonalDataAsync",
"parametersOnMethod": [
{
"name": "requestId",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"returnValue": {
"type": "Volo.Abp.Content.IRemoteStreamContent",
"typeSimple": "Volo.Abp.Content.IRemoteStreamContent"
}
},
{
"name": "DeleteAsync",
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
}
},
{
"name": "PreparePersonalDataAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
}
},
{
"name": "DeletePersonalDataAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
}
},
{
"name": "DeletePersonalAccountAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
}
}
]
}
],
"actions": {
"DeleteAsyncById": {
"uniqueName": "DeleteAsyncById",
"name": "DeleteAsync",
"httpMethod": "DELETE",
"url": "api/gdpr/requests/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"DeletePersonalAccountAsync": {
"uniqueName": "DeletePersonalAccountAsync",
"name": "DeletePersonalAccountAsync",
"httpMethod": "DELETE",
"url": "api/gdpr/requests/personal-account",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"DeletePersonalDataAsync": {
"uniqueName": "DeletePersonalDataAsync",
"name": "DeletePersonalDataAsync",
"httpMethod": "DELETE",
"url": "api/gdpr/requests/personal-data",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"GetAsyncById": {
"uniqueName": "GetAsyncById",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/gdpr/requests/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "LINGYUN.Abp.Gdpr.GdprRequestDto",
"typeSimple": "LINGYUN.Abp.Gdpr.GdprRequestDto"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"GetListAsyncByInput": {
"uniqueName": "GetListAsyncByInput",
"name": "GetListAsync",
"httpMethod": "GET",
"url": "api/gdpr/requests",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput, LINGYUN.Abp.Gdpr.Application.Contracts",
"type": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput",
"typeSimple": "LINGYUN.Abp.Gdpr.GdprRequestGetListInput",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "CreationTime",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "ReadyTime",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Sorting",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "SkipCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "MaxResultCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.PagedResultDto<LINGYUN.Abp.Gdpr.GdprRequestDto>",
"typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto<LINGYUN.Abp.Gdpr.GdprRequestDto>"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"DownloadPersonalDataAsyncByRequestId": {
"uniqueName": "DownloadPersonalDataAsyncByRequestId",
"name": "DownloadPersonalDataAsync",
"httpMethod": "GET",
"url": "api/gdpr/requests/personal-data/download/{requestId}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "requestId",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "requestId",
"name": "requestId",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "Volo.Abp.Content.IRemoteStreamContent",
"typeSimple": "Volo.Abp.Content.IRemoteStreamContent"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
},
"PreparePersonalDataAsync": {
"uniqueName": "PreparePersonalDataAsync",
"name": "PreparePersonalDataAsync",
"httpMethod": "POST",
"url": "api/gdpr/requests/personal-data/prepare",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "LINGYUN.Abp.Gdpr.IGdprRequestAppService"
}
}
}
}
}
},
"types": {}
}

3
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

32
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/LINGYUN.Abp.Gdpr.HttpApi.Client.csproj

@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks>
<AssemblyName>LINGYUN.Abp.Gdpr.HttpApi.Client</AssemblyName>
<PackageId>LINGYUN.Abp.Gdpr.HttpApi.Client</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="ClientProxies\gdpr-generate-proxy.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ClientProxies\gdpr-generate-proxy.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Http.Client" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Gdpr.Application.Contracts\LINGYUN.Abp.Gdpr.Application.Contracts.csproj" />
</ItemGroup>
</Project>

24
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.HttpApi.Client/LINGYUN/Abp/Gdpr/AbpGdprHttpApiClientModule.cs

@ -0,0 +1,24 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Gdpr;
[DependsOn(
typeof(AbpGdprApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class AbpGdprHttpApiClientModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddStaticHttpClientProxies(
typeof(AbpGdprApplicationContractsModule).Assembly,
GdprRemoteServiceConsts.RemoteServiceName);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpGdprHttpApiClientModule>();
});
}
}
Loading…
Cancel
Save