From 595dc1e1a67a0401d69b9fdfee35020ba7096b42 Mon Sep 17 00:00:00 2001 From: iamshen Date: Wed, 24 Jul 2024 16:21:22 +0800 Subject: [PATCH 1/4] feat: Agree to API return values --- .../ApiExtensions/ApiExtensions.xml | 20 +++++ .../ApiExtensions/Filters/ModelStateFilter.cs | 62 ++++++++++++++ .../Middleware/ResultMiddleware.cs | 80 +++++++++++++++++++ .../Middleware/ResultMiddlewareExtensions.cs | 11 +++ .../ApiExtensions/WebApplicationExtensions.cs | 3 + .../Mobile/PurchaseController.cs | 6 +- .../Presentation/Ordering.Api/Program.cs | 4 +- 7 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 src/BuildingBlocks/ApiExtensions/Filters/ModelStateFilter.cs create mode 100644 src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs create mode 100644 src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddlewareExtensions.cs diff --git a/src/BuildingBlocks/ApiExtensions/ApiExtensions.xml b/src/BuildingBlocks/ApiExtensions/ApiExtensions.xml index 87a4ff2..4b87009 100644 --- a/src/BuildingBlocks/ApiExtensions/ApiExtensions.xml +++ b/src/BuildingBlocks/ApiExtensions/ApiExtensions.xml @@ -297,6 +297,26 @@ + + + Action执行之后的事件 + + + + + + Action执行前检查数据模型是否通过验证 + + + + + + 获取验证模型的错误消息 + + + + + 统一返回格式的内容的Fileter diff --git a/src/BuildingBlocks/ApiExtensions/Filters/ModelStateFilter.cs b/src/BuildingBlocks/ApiExtensions/Filters/ModelStateFilter.cs new file mode 100644 index 0000000..3e7e865 --- /dev/null +++ b/src/BuildingBlocks/ApiExtensions/Filters/ModelStateFilter.cs @@ -0,0 +1,62 @@ +using DaprTool.BuildingBlocks.Utils; +using DaprTool.BuildingBlocks.Utils.ValueObjects; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Microsoft.AspNetCore.Mvc.Filters; + +public class ModelStateFilter : IActionFilter +{ + #region Action执行之后的事件 + + /// + /// Action执行之后的事件 + /// + /// + public void OnActionExecuted(ActionExecutedContext context) + { + } + + #endregion + + #region Action执行前检查数据模型是否通过验证 + + /// + /// Action执行前检查数据模型是否通过验证 + /// + /// + public void OnActionExecuting(ActionExecutingContext context) + { + if (context.ModelState.IsValid) return; + + var version = context.HttpContext.GetRequestedApiVersion()?.ToString() ?? "1.0"; + var traceId = context.HttpContext.TraceIdentifier; + context.Result = new OkObjectResult(ResponseResult.Failed(ErrorCode.ArgumentException, version, traceId, + context.ModelState.GetErrorMessage())); + } + + #endregion +} + +public static class ModelStateExtensions +{ + #region 获取验证模型的错误消息 + + /// + /// 获取验证模型的错误消息 + /// + /// + /// + /// + public static string GetErrorMessage(this ModelStateDictionary state, string split = ";") + { + var errors = state + .Where(e => e.Value != null && e.Value.Errors.Any()) + .Select(m + => $"{string.Join(",", m.Value?.Errors?.Select(error => error.ErrorMessage) ?? new[] { "" })} [{m.Key}]"); + + return string.Join(split, errors); + } + + #endregion +} \ No newline at end of file diff --git a/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs new file mode 100644 index 0000000..744d5c2 --- /dev/null +++ b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs @@ -0,0 +1,80 @@ +using System.Reflection; +using DaprTool.BuildingBlocks.Utils.ValueObjects; +using DaprTool.BuildingBlocks.Utils; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc; +using Asp.Versioning; + +namespace DaprTool.BuildingBlocks.ApiExtensions.Middleware; + + +public class ResultMiddleware(RequestDelegate next) +{ + public async Task InvokeAsync(HttpContext context) + { + // Call the next middleware in the pipeline + await next(context); + + // After the response is created, process it + if (context.Response.HasStarted) + { + return; + } + + var endpoint = context.GetEndpoint(); + var actionDescriptor = endpoint?.Metadata?.GetMetadata(); + + if (actionDescriptor != null) + { + var controlsProduces = actionDescriptor.ControllerTypeInfo.GetCustomAttribute(); + var actionProduces = actionDescriptor.MethodInfo.GetCustomAttribute(); + if (controlsProduces is null && actionProduces is null && !(context.Response.ContentType?.Contains("text/html") ?? false)) + { + var version = context.GetRequestedApiVersion(1).ToString(); + var traceId = context.TraceIdentifier; + object returnObject = null; + + if (context.Response.StatusCode == StatusCodes.Status200OK) + { + if (context.Response.Body.Length > 0) + { + // Assuming the response body is JSON serialized and deserializing it. + context.Response.Body.Seek(0, System.IO.SeekOrigin.Begin); + using (var reader = new System.IO.StreamReader(context.Response.Body)) + { + var responseBody = await reader.ReadToEndAsync(); + returnObject = ResponseResult.Succeed(responseBody, version, traceId); + } + } + else + { + returnObject = ResponseResult.Succeed(version: version, traceId: traceId); + } + } + else if (context.Response.StatusCode != StatusCodes.Status204NoContent) + { + returnObject = ResponseResult.Failed(ErrorCode.Unknown, $"Http Code: {context.Response.StatusCode}", version, traceId); + } + + if (returnObject != null) + { + context.Response.ContentType = "application/json"; + context.Response.Body.Seek(0, System.IO.SeekOrigin.Begin); + await context.Response.WriteAsync(System.Text.Json.JsonSerializer.Serialize(returnObject)); + } + } + } + } +} + +// Extension method used to add the middleware to the HTTP request pipeline. + +public static class HttpContextExtensions +{ + public static ApiVersion GetRequestedApiVersion(this HttpContext context, int defaultVersion) + { + var ver = context.GetRequestedApiVersion(); + return ver ?? new ApiVersion(defaultVersion, 0); + } +} \ No newline at end of file diff --git a/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddlewareExtensions.cs b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddlewareExtensions.cs new file mode 100644 index 0000000..4028e14 --- /dev/null +++ b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddlewareExtensions.cs @@ -0,0 +1,11 @@ +using DaprTool.BuildingBlocks.ApiExtensions.Middleware; + +namespace Microsoft.AspNetCore.Builder; + +public static class ResultMiddlewareExtensions +{ + public static IApplicationBuilder UseResultMiddleware(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } +} \ No newline at end of file diff --git a/src/BuildingBlocks/ApiExtensions/WebApplicationExtensions.cs b/src/BuildingBlocks/ApiExtensions/WebApplicationExtensions.cs index 5010217..0d5bcd2 100644 --- a/src/BuildingBlocks/ApiExtensions/WebApplicationExtensions.cs +++ b/src/BuildingBlocks/ApiExtensions/WebApplicationExtensions.cs @@ -33,7 +33,10 @@ public static class WebApplicationExtensions builder.Services.AddControllers(options => { // 注册过滤器 + // 数模模型检查过滤器 + // options.Filters.Add(new ModelStateFilter()); // options.Filters.Add(); + // 返回结果处理过滤器 (改用 Middleware/ResultMiddleware) options.Filters.Add(new ResultFilter(AspNetCore.Mvc.AppConstants.ResponseJsonContentType)); }); // 注册 自动依赖注入 diff --git a/src/Services/Ordering/Presentation/Ordering.Api/Controllers/PurchaseOrder/Mobile/PurchaseController.cs b/src/Services/Ordering/Presentation/Ordering.Api/Controllers/PurchaseOrder/Mobile/PurchaseController.cs index a20d25d..0d209d2 100644 --- a/src/Services/Ordering/Presentation/Ordering.Api/Controllers/PurchaseOrder/Mobile/PurchaseController.cs +++ b/src/Services/Ordering/Presentation/Ordering.Api/Controllers/PurchaseOrder/Mobile/PurchaseController.cs @@ -22,9 +22,9 @@ public class PurchaseController(IPurchaseOrderApiService apiApiService) : Mobile /// 订单Id /// [HttpGet("Get")] - [ProducesResponseType(typeof(PurchaseOrderOutputDto), 200)] + [ProducesResponseType(typeof(ResponseResult), 200)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public async Task GetAsync(string id) + public async Task GetAsync([FromQuery]string id) { var result = await apiApiService.GetAsync(id); return result.ToOkResult(data => data); @@ -36,7 +36,7 @@ public class PurchaseController(IPurchaseOrderApiService apiApiService) : Mobile /// 订单号 /// [HttpGet("Detail")] - [ProducesResponseType(typeof(PurchaseOrderOutputDto), 200)] + [ProducesResponseType(typeof(ResponseResult), 200)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task GetDetailAsync(string orderNumber) { diff --git a/src/Services/Ordering/Presentation/Ordering.Api/Program.cs b/src/Services/Ordering/Presentation/Ordering.Api/Program.cs index 2016cdb..9f2a2bf 100644 --- a/src/Services/Ordering/Presentation/Ordering.Api/Program.cs +++ b/src/Services/Ordering/Presentation/Ordering.Api/Program.cs @@ -18,11 +18,9 @@ builder.RegisterAppDapr(options => var app = builder.Build(); - -app.MapDefaultEndpoints(); - app.UseAppServer(builder.Configuration); +app.MapDefaultEndpoints(); app.MapGet("/", () => Results.LocalRedirect("~/docs")); app.MapControllers(); app.MapSubscribeHandler(); -- Gitee From 576c00cecb29c9ede368583c7665d4c960bd202c Mon Sep 17 00:00:00 2001 From: iamshen Date: Wed, 24 Jul 2024 16:40:37 +0800 Subject: [PATCH 2/4] update: Upgrade .Net Aspire to 8.1.0 --- Directory.Packages.props | 18 ++--- .../aspirate-output/docker-compose.yaml | 76 ++++++++++--------- .../aspirate-state.json | 2 +- build/DaprTool.Solution.AppHost/aspirate.json | 2 +- build/DaprTool.Solution.AppHost/manifest.json | 69 ++++++++++------- 5 files changed, 93 insertions(+), 74 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index a64a94d..1088ca0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -128,15 +128,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/build/DaprTool.Solution.AppHost/aspirate-output/docker-compose.yaml b/build/DaprTool.Solution.AppHost/aspirate-output/docker-compose.yaml index bf1eca3..f2f7ed7 100644 --- a/build/DaprTool.Solution.AppHost/aspirate-output/docker-compose.yaml +++ b/build/DaprTool.Solution.AppHost/aspirate-output/docker-compose.yaml @@ -8,126 +8,133 @@ services: - target: 18888 published: 18888 restart: unless-stopped - admin: - container_name: "admin" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/web-admin:1.0.12-alpha1" + auth-sts: + container_name: "auth-sts" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-sts:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889" - OTEL_SERVICE_NAME: "admin" + OTEL_SERVICE_NAME: "auth-sts" ports: - target: 8080 published: 10000 - target: 8443 published: 10001 restart: unless-stopped - admin-dapr: - network_mode: "service:admin" + auth-sts-dapr: + network_mode: "service:auth-sts" image: "daprio/daprd:latest" command: - "./daprd" - "-app-id" - - "admin" + - "auth-sts" - "-app-port" - "8080" restart: unless-stopped depends_on: - - "admin" - auth-sts: - container_name: "auth-sts" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-sts:1.0.12-alpha1" + - "auth-sts" + auth-admin: + container_name: "auth-admin" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-admin:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889" - OTEL_SERVICE_NAME: "auth-sts" + OTEL_SERVICE_NAME: "auth-admin" ports: - target: 8080 published: 10002 - target: 8443 published: 10003 restart: unless-stopped - auth-sts-dapr: - network_mode: "service:auth-sts" + auth-admin-dapr: + network_mode: "service:auth-admin" image: "daprio/daprd:latest" command: - "./daprd" - "-app-id" - - "auth-sts" + - "auth-admin" - "-app-port" - "8080" restart: unless-stopped depends_on: - - "auth-sts" - auth-admin: - container_name: "auth-admin" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-admin:1.0.12-alpha1" + - "auth-admin" + auth-api: + container_name: "auth-api" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-api:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889" - OTEL_SERVICE_NAME: "auth-admin" + OTEL_SERVICE_NAME: "auth-api" ports: - target: 8080 published: 10004 - target: 8443 published: 10005 restart: unless-stopped - auth-admin-dapr: - network_mode: "service:auth-admin" + auth-api-dapr: + network_mode: "service:auth-api" image: "daprio/daprd:latest" command: - "./daprd" - "-app-id" - - "auth-admin" + - "auth-api" - "-app-port" - "8080" restart: unless-stopped depends_on: - - "auth-admin" - auth-api: - container_name: "auth-api" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/auth-api:1.0.12-alpha1" + - "auth-api" + admin: + container_name: "admin" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/web-admin:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" + services__auth-sts__http__0: "http://auth-sts:8080" + services__auth-api__http__0: "http://auth-api:8080" OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889" - OTEL_SERVICE_NAME: "auth-api" + OTEL_SERVICE_NAME: "admin" ports: - target: 8080 published: 10006 - target: 8443 published: 10007 restart: unless-stopped - auth-api-dapr: - network_mode: "service:auth-api" + admin-dapr: + network_mode: "service:admin" image: "daprio/daprd:latest" command: - "./daprd" - "-app-id" - - "auth-api" + - "admin" - "-app-port" - "8080" restart: unless-stopped depends_on: - - "auth-api" + - "admin" order: container_name: "order" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/order-api:1.0.12-alpha1" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/order-api:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889" OTEL_SERVICE_NAME: "order" ports: @@ -150,12 +157,13 @@ services: - "order" proxy-server: container_name: "proxy-server" - image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/proxy-server:1.0.12-alpha1" + image: "registry.cn-shenzhen.aliyuncs.com/project-workspace/proxy-server:1.0.13-alpha1" environment: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true" + HTTP_PORTS: "8080" services__admin__http__0: "http://admin:8080" services__auth-admin__http__0: "http://auth-admin:8080" services__auth-sts__http__0: "http://auth-sts:8080" diff --git a/build/DaprTool.Solution.AppHost/aspirate-state.json b/build/DaprTool.Solution.AppHost/aspirate-state.json index 04e60c5..d71b4fc 100644 --- a/build/DaprTool.Solution.AppHost/aspirate-state.json +++ b/build/DaprTool.Solution.AppHost/aspirate-state.json @@ -4,7 +4,7 @@ "namespace": "dapr-playground", "containerRegistry": "registry.cn-shenzhen.aliyuncs.com", "containerImageTags": [ - "1.0.12-alpha1", + "1.0.13-alpha1", "latest" ], "imagePullPolicy": "IfNotPresent", diff --git a/build/DaprTool.Solution.AppHost/aspirate.json b/build/DaprTool.Solution.AppHost/aspirate.json index a964fe5..e4f06cb 100644 --- a/build/DaprTool.Solution.AppHost/aspirate.json +++ b/build/DaprTool.Solution.AppHost/aspirate.json @@ -4,7 +4,7 @@ "Registry": "registry.cn-shenzhen.aliyuncs.com", "RepositoryPrefix": "project-workspace", "Tags": [ - "1.0.7-alpha1", + "1.0.13-alpha1", "latest" ], "Builder": "docker" diff --git a/build/DaprTool.Solution.AppHost/manifest.json b/build/DaprTool.Solution.AppHost/manifest.json index de940a1..ac761ae 100644 --- a/build/DaprTool.Solution.AppHost/manifest.json +++ b/build/DaprTool.Solution.AppHost/manifest.json @@ -1,13 +1,15 @@ { + "$schema": "https://json.schemastore.org/aspire-8.0.json", "resources": { - "admin": { + "auth-sts": { "type": "project.v0", - "path": "../../src/Web/WebAdmin/WebAdmin.csproj", + "path": "../../src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj", "env": { "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true" + "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{auth-sts.bindings.http.targetPort}" }, "bindings": { "http": { @@ -24,27 +26,28 @@ } } }, - "admin-dapr": { + "auth-sts-dapr": { "type": "dapr.v0", "dapr": { - "application": "admin", - "appId": "admin", + "application": "auth-sts", + "appId": "auth-sts", "daprHttpMaxRequestSize": 60, - "daprHttpPort": 23301, + "daprHttpPort": 23304, "daprHttpReadBufferSize": 128, "resourcesPath": [ "../../dapr/components" ] } }, - "auth-sts": { + "auth-admin": { "type": "project.v0", - "path": "../../src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj", + "path": "../../src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj", "env": { "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true" + "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{auth-admin.bindings.http.targetPort}" }, "bindings": { "http": { @@ -61,27 +64,28 @@ } } }, - "auth-sts-dapr": { + "auth-admin-dapr": { "type": "dapr.v0", "dapr": { - "application": "auth-sts", - "appId": "auth-sts", + "application": "auth-admin", + "appId": "auth-admin", "daprHttpMaxRequestSize": 60, - "daprHttpPort": 23304, + "daprHttpPort": 23303, "daprHttpReadBufferSize": 128, "resourcesPath": [ "../../dapr/components" ] } }, - "auth-admin": { + "auth-api": { "type": "project.v0", - "path": "../../src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj", + "path": "../../src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj", "env": { "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true" + "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{auth-api.bindings.http.targetPort}" }, "bindings": { "http": { @@ -98,27 +102,32 @@ } } }, - "auth-admin-dapr": { + "auth-api-dapr": { "type": "dapr.v0", "dapr": { - "application": "auth-admin", - "appId": "auth-admin", + "application": "auth-api", + "appId": "auth-api", "daprHttpMaxRequestSize": 60, - "daprHttpPort": 23303, + "daprHttpPort": 23302, "daprHttpReadBufferSize": 128, "resourcesPath": [ "../../dapr/components" ] } }, - "auth-api": { + "admin": { "type": "project.v0", - "path": "../../src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj", + "path": "../../src/Web/WebAdmin/WebAdmin.csproj", "env": { "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true" + "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{admin.bindings.http.targetPort}", + "services__auth-sts__http__0": "{auth-sts.bindings.http.url}", + "services__auth-sts__https__0": "{auth-sts.bindings.https.url}", + "services__auth-api__http__0": "{auth-api.bindings.http.url}", + "services__auth-api__https__0": "{auth-api.bindings.https.url}" }, "bindings": { "http": { @@ -135,13 +144,13 @@ } } }, - "auth-api-dapr": { + "admin-dapr": { "type": "dapr.v0", "dapr": { - "application": "auth-api", - "appId": "auth-api", + "application": "admin", + "appId": "admin", "daprHttpMaxRequestSize": 60, - "daprHttpPort": 23302, + "daprHttpPort": 23301, "daprHttpReadBufferSize": 128, "resourcesPath": [ "../../dapr/components" @@ -155,7 +164,8 @@ "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", - "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true" + "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{order.bindings.http.targetPort}" }, "bindings": { "http": { @@ -193,6 +203,7 @@ "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", + "HTTP_PORTS": "{proxy-server.bindings.http.targetPort}", "services__admin__http__0": "{admin.bindings.http.url}", "services__admin__https__0": "{admin.bindings.https.url}", "services__auth-admin__http__0": "{auth-admin.bindings.http.url}", -- Gitee From f750f789b3e4baadcf3ee17d68d8d25566a09dec Mon Sep 17 00:00:00 2001 From: iamshen Date: Tue, 5 Nov 2024 14:46:30 +0800 Subject: [PATCH 3/4] Updating dependencies --- DaprTool.Solution.sln | 6 - Directory.Packages.props | 322 +++++++++--------- README.md | 1 - dapr/components/dt-configurationstore.yaml | 4 +- .../Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj | 2 - .../src/Idsrv4.Admin.Api/appsettings.json | 12 +- .../src/Idsrv4.Admin.STS.Identity/Program.cs | 33 +- .../appsettings.json | 8 +- .../src/Idsrv4.Admin/appsettings.json | 12 +- .../src/Idsrv4.Admin/identityserverdata.json | 24 +- .../Ordering.Api/appsettings.json | 6 +- .../WebAdmin.Shared/Layout/MainLayout.razor | 2 +- src/Web/WebAdmin/appsettings.Development.json | 6 +- .../DaprTool.AbstractionsTest.csproj | 10 +- 14 files changed, 227 insertions(+), 221 deletions(-) diff --git a/DaprTool.Solution.sln b/DaprTool.Solution.sln index 4eeb432..0498ee3 100644 --- a/DaprTool.Solution.sln +++ b/DaprTool.Solution.sln @@ -81,11 +81,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", dapr\components\dt-statestore.yaml = dapr\components\dt-statestore.yaml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "configuration", "configuration", "{F3C8590F-504F-42D5-A120-198B742CCFF6}" - ProjectSection(SolutionItems) = preProject - dapr\configuration\dt-config.yaml = dapr\configuration\dt-config.yaml - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{957DAFBB-1DA6-4AB2-BCC3-D984E7C7F4A8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Swagger", "src\BuildingBlocks\Swagger\Swagger.csproj", "{09190F8C-A670-4D83-A692-A89637823BF2}" @@ -405,7 +400,6 @@ Global {90BDC411-E19C-4781-BD46-94C688BE797F} = {E2CF6914-DBA1-47C6-B445-A08560FB8BF9} {5A8422B2-1F0D-41BE-8C30-5810D4C7D448} = {121D78F3-3F0F-4F00-B2C9-3C797653C951} {56D45039-23D5-47CB-B12B-CE4982E85633} = {B75B1640-466C-4BAB-8EEF-2F0B3691FD77} - {F3C8590F-504F-42D5-A120-198B742CCFF6} = {B75B1640-466C-4BAB-8EEF-2F0B3691FD77} {09190F8C-A670-4D83-A692-A89637823BF2} = {121D78F3-3F0F-4F00-B2C9-3C797653C951} {7F1A5FE9-2793-4B98-B817-6D3A7F151609} = {121D78F3-3F0F-4F00-B2C9-3C797653C951} {96AB328E-BA32-499A-AF9B-B7CC67703514} = {DE45A29E-9213-401C-8D14-3157C8784072} diff --git a/Directory.Packages.props b/Directory.Packages.props index 1088ca0..412febf 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,163 +1,163 @@ - - true - - - 8.0.0 - 8.0.0 - 8.0.4 - 1.13.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + true + + + 8.0.0 + 8.0.0 + 8.0.4 + 1.13.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index db1c07d..8949349 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,6 @@ visual studio 2022 p > 本地测试 可插拔组件的时候 请使用 wsl 运行 dotnet run - ### IdentityServer4 #### 数据库准备 diff --git a/dapr/components/dt-configurationstore.yaml b/dapr/components/dt-configurationstore.yaml index a25b275..d86e2b5 100644 --- a/dapr/components/dt-configurationstore.yaml +++ b/dapr/components/dt-configurationstore.yaml @@ -8,8 +8,8 @@ spec: version: v1 metadata: - name: connectionString - value: "host=192.168.8.111 user=dapr password=Local@Db port=5432 connect_timeout=10 database=dapr_manager" + value: "host=192.168.10.111 user=dapr password=Local@Db port=5432 connect_timeout=10 database=dapr_manager" - name: table # name of the table which holds configuration information - value: "dapr_appsettings" + value: "appsettings" - name: connMaxIdleTime # max timeout for connection value : "15s" diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj b/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj index f2ab51e..5c441b1 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj @@ -8,10 +8,8 @@ mcr.microsoft.com/dotnet/aspnet:8.0 - - diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Api/appsettings.json b/src/IdentityServer4/src/Idsrv4.Admin.Api/appsettings.json index 06a8a13..3a6e015 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Api/appsettings.json +++ b/src/IdentityServer4/src/Idsrv4.Admin.Api/appsettings.json @@ -1,11 +1,11 @@ { "ConnectionStrings": { - "ConfigurationDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "PersistedGrantDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "IdentityDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "AdminLogDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "AdminAuditLogDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "DataProtectionDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" + "ConfigurationDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "PersistedGrantDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "IdentityDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "AdminLogDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "AdminAuditLogDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "DataProtectionDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" }, "AdminApiConfiguration": { "ApiName": "IdentityServer4 Admin Api", diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Program.cs b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Program.cs index 4761ea8..7f1e0ba 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Program.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Program.cs @@ -1,4 +1,4 @@ -using Idsrv4.Admin.Shared.ModuleInitializer; +using IdentityServer4.Extensions; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Logging; @@ -25,9 +25,12 @@ try #region Configuration IRootConfiguration rootConfiguration = new RootConfiguration(); - builder.Configuration.GetSection(ConfigurationConsts.AdminConfigurationKey).Bind(rootConfiguration.AdminConfiguration); - builder.Configuration.GetSection(ConfigurationConsts.RegisterConfigurationKey).Bind(rootConfiguration.RegisterConfiguration); + builder.Configuration.GetSection(ConfigurationConsts.AdminConfigurationKey) + .Bind(rootConfiguration.AdminConfiguration); + builder.Configuration.GetSection(ConfigurationConsts.RegisterConfigurationKey) + .Bind(rootConfiguration.RegisterConfiguration); builder.Services.AddSingleton(rootConfiguration); + #endregion #region Services @@ -85,15 +88,15 @@ try IdentityModelEventSource.ShowPII = true; // Add custom security headers app.UseSecurityHeaders(builder.Configuration); - - #region BasePath - string basePath = builder.Configuration.GetValue("BasePath"); + #region BasePath + + var basePath = builder.Configuration.GetValue("BasePath"); if (!string.IsNullOrWhiteSpace(basePath)) - app.UsePathBase(new PathString(basePath)); + app.UsePathBase(new PathString(basePath)); + + #endregion - #endregion - app.UseCookiePolicy(); if (app.Environment.IsDevelopment()) @@ -102,6 +105,13 @@ try app.UseHsts(); + //if (!string.IsNullOrWhiteSpace(rootConfiguration.AdminConfiguration.ProxyServerUrl)) + // app.Use(async (ctx, next) => + // { + // ctx.SetIdentityServerOrigin(string.Concat(rootConfiguration.AdminConfiguration.ProxyServerUrl, basePath)); + // await next(); + // }); + app.UseStaticFiles(); app.UseIdentityServer(); @@ -113,7 +123,7 @@ try app.MapDefaultEndpoints(); app.MapDefaultControllerRoute(); - + await app.RunAsync(); } @@ -124,5 +134,4 @@ catch (Exception ex) finally { await Log.CloseAndFlushAsync(); -} - +} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json index f66eb09..fc7ca6e 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/appsettings.json @@ -1,9 +1,9 @@ { "ConnectionStrings": { - "ConfigurationDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "PersistedGrantDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "IdentityDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "DataProtectionDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" + "ConfigurationDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "PersistedGrantDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "IdentityDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "DataProtectionDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" }, "DatabaseProviderConfiguration": { "ProviderType": "PostgreSQL" diff --git a/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json b/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json index f1a6df3..0fca234 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json +++ b/src/IdentityServer4/src/Idsrv4.Admin/appsettings.json @@ -1,11 +1,11 @@ { "ConnectionStrings": { - "ConfigurationDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "PersistedGrantDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "IdentityDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "AdminLogDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "AdminAuditLogDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "DataProtectionDbConnection": "Server=192.168.8.112;Port=5432;Database=idsrv4;User Id=idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" + "ConfigurationDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "PersistedGrantDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "IdentityDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "AdminLogDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "AdminAuditLogDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "DataProtectionDbConnection": "Server=192.168.10.111;Port=5432;Database=dapr_idsrv4;User Id=dapr_idsrv4;Password=Local@Db;Pooling=true;MaxPoolSize=100;" }, "SeedConfiguration": { "ApplySeed": false diff --git a/src/IdentityServer4/src/Idsrv4.Admin/identityserverdata.json b/src/IdentityServer4/src/Idsrv4.Admin/identityserverdata.json index 1048c26..aaaf74f 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin/identityserverdata.json +++ b/src/IdentityServer4/src/Idsrv4.Admin/identityserverdata.json @@ -84,7 +84,7 @@ { "ClientId": "web_admin", "ClientName": "web_admin", - "ClientUri": "https://localhost:44444/admin", + "ClientUri": "http://localhost:24400/admin", "AllowOfflineAccess": true, "AllowedGrantTypes": [ "authorization_code" @@ -96,14 +96,14 @@ } ], "RedirectUris": [ - "https://localhost:44444/admin/signin-oidc" + "http://localhost:24400/admin/signin-oidc" ], - "FrontChannelLogoutUri": "https://localhost:44444/admin/signout-oidc", + "FrontChannelLogoutUri": "http://localhost:24400/admin/signout-oidc", "PostLogoutRedirectUris": [ - "https://localhost:44444/admin/signout-callback-oidc" + "http://localhost:24400/admin/signout-callback-oidc" ], "AllowedCorsOrigins": [ - "https://localhost:44444" + "http://localhost:24400" ], "AllowedScopes": [ "roles", @@ -117,7 +117,7 @@ { "ClientId": "identity_admin", "ClientName": "identity_admin", - "ClientUri": "https://localhost:44444/auth/admin", + "ClientUri": "http://localhost:24400/auth/admin", "AllowedGrantTypes": [ "authorization_code" ], @@ -128,14 +128,14 @@ } ], "RedirectUris": [ - "https://localhost:44444/auth/admin/signin-oidc" + "http://localhost:24400/auth/admin/signin-oidc" ], - "FrontChannelLogoutUri": "https://localhost:44444/auth/admin/signout-oidc", + "FrontChannelLogoutUri": "http://localhost:24400/auth/admin/signout-oidc", "PostLogoutRedirectUris": [ - "https://localhost:44444/auth/admin/signout-callback-oidc" + "http://localhost:24400/auth/admin/signout-callback-oidc" ], "AllowedCorsOrigins": [ - "https://localhost:44444" + "http://localhost:24400" ], "AllowedScopes": [ "openid", @@ -153,13 +153,13 @@ "RequireClientSecret": false, "RequirePkce": true, "RedirectUris": [ - "https://localhost:44302/swagger/oauth2-redirect.html" + "http://localhost:24400/api/auth/swagger/oauth2-redirect.html" ], "AllowedScopes": [ "identity_admin_api" ], "AllowedCorsOrigins": [ - "https://localhost:44302" + "http://localhost:24400" ] } ] diff --git a/src/Services/Ordering/Presentation/Ordering.Api/appsettings.json b/src/Services/Ordering/Presentation/Ordering.Api/appsettings.json index 27c7d85..1354859 100644 --- a/src/Services/Ordering/Presentation/Ordering.Api/appsettings.json +++ b/src/Services/Ordering/Presentation/Ordering.Api/appsettings.json @@ -10,9 +10,9 @@ } }, "ConnectionStrings": { - "catalog": "Server=192.168.8.112;Port=5432;Database=dapr_catalog;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "identity": "Server=192.168.8.112;Port=5432;Database=dapr_identity;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "order": "Server=192.168.8.112;Port=5432;Database=dapr_ordering;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;" + "catalog": "Server=192.168.10.111;Port=5432;Database=dapr_catalog;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "identity": "Server=192.168.10.111;Port=5432;Database=dapr_identity;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "order": "Server=192.168.10.111;Port=5432;Database=dapr_ordering;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;" }, "AllowedHosts": "*", "GracePeriodTime": "1", diff --git a/src/Web/WebAdmin.Shared/Layout/MainLayout.razor b/src/Web/WebAdmin.Shared/Layout/MainLayout.razor index 4df9b3b..e9658a7 100644 --- a/src/Web/WebAdmin.Shared/Layout/MainLayout.razor +++ b/src/Web/WebAdmin.Shared/Layout/MainLayout.razor @@ -36,7 +36,7 @@ - + diff --git a/src/Web/WebAdmin/appsettings.Development.json b/src/Web/WebAdmin/appsettings.Development.json index 5198043..6babbe3 100644 --- a/src/Web/WebAdmin/appsettings.Development.json +++ b/src/Web/WebAdmin/appsettings.Development.json @@ -11,9 +11,9 @@ "AllowedHosts": "*", "ConnectionStrings": { - "Catalog": "Server=192.168.8.112;Port=5432;Database=dapr_catalog;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "Identity": "Server=192.168.8.112;Port=5432;Database=dapr_identity;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", - "Ordering": "Server=192.168.8.112;Port=5432;Database=dapr_ordering;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;" + "Catalog": "Server=192.168.10.111;Port=5432;Database=dapr_catalog;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "Identity": "Server=192.168.10.111;Port=5432;Database=dapr_identity;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;", + "Ordering": "Server=192.168.10.111;Port=5432;Database=dapr_ordering;User Id=dapr;Password=Local@Db;Pooling=true;MaxPoolSize=100;" }, "AdminConfiguration": { diff --git a/test/DaprTool.AbstractionsTest/DaprTool.AbstractionsTest.csproj b/test/DaprTool.AbstractionsTest/DaprTool.AbstractionsTest.csproj index 38efdeb..c7d518c 100644 --- a/test/DaprTool.AbstractionsTest/DaprTool.AbstractionsTest.csproj +++ b/test/DaprTool.AbstractionsTest/DaprTool.AbstractionsTest.csproj @@ -8,9 +8,15 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + -- Gitee From 59e8a371fbf4102a3681a83e211d9d5a5b972a42 Mon Sep 17 00:00:00 2001 From: iamshen Date: Fri, 13 Dec 2024 15:35:14 +0800 Subject: [PATCH 4/4] .NET 9 Migration --- Common.props | 2 +- Directory.Packages.props | 318 +++++++++--------- .../DaprTool.Solution.AppHost.csproj | 2 + samples/Client/SampleClient.csproj | 2 +- samples/Interfaces/SampleInterfaces.csproj | 2 +- samples/Service/SampleService.csproj | 2 +- .../Middleware/ResultMiddleware.cs | 2 +- .../Helpers/StartupHelpers.cs | 2 - .../Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj | 2 +- ....Admin.AuditLogging.EntityFramework.csproj | 2 +- .../HttpContextHelpers/HttpContextHelpers.cs | 2 +- .../Idsrv4.Admin.AuditLogging.csproj | 2 +- ...Idsrv4.Admin.BusinessLogic.Identity.csproj | 2 +- .../Idsrv4.Admin.BusinessLogic.Shared.csproj | 2 +- .../Idsrv4.Admin.BusinessLogic.csproj | 2 +- ...Admin.EntityFramework.Configuration.csproj | 5 +- .../MySql/DatabaseExtensions.cs | 130 ------- .../SqlServer/DatabaseExtensions.cs | 120 ------- ...v4.Admin.EntityFramework.Extensions.csproj | 2 +- ...srv4.Admin.EntityFramework.Identity.csproj | 2 +- ...v4.Admin.EntityFramework.PostgreSQL.csproj | 2 +- ...Idsrv4.Admin.EntityFramework.Shared.csproj | 2 +- .../Idsrv4.Admin.EntityFramework.csproj | 2 +- .../Helpers/StartupHelpers.cs | 2 - .../Idsrv4.Admin.STS.Identity.csproj | 6 +- .../Idsrv4.Admin.Shared.Configuration.csproj | 2 +- .../Idsrv4.Admin.Shared.csproj | 2 +- .../Idsrv4.Admin.UI/Helpers/StartupHelpers.cs | 2 - .../Idsrv4.Admin.UI/Idsrv4.Admin.UI.csproj | 4 +- .../src/Idsrv4.Admin/Idsrv4.Admin.csproj | 2 +- .../PluggableComponents.csproj | 2 +- .../DataBases/JsonQueryTest.cs | 4 +- 32 files changed, 186 insertions(+), 451 deletions(-) delete mode 100644 src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/MySql/DatabaseExtensions.cs delete mode 100644 src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/SqlServer/DatabaseExtensions.cs diff --git a/Common.props b/Common.props index b15a115..7ae7792 100644 --- a/Common.props +++ b/Common.props @@ -1,7 +1,7 @@ latest - net8.0 + net9.0 enable enable $(NoWarn);NU1803;NU1507;1701;1702;1591;8002;CS1573; diff --git a/Directory.Packages.props b/Directory.Packages.props index 412febf..81fd3f7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,163 +1,159 @@ - - true - - - 8.0.0 - 8.0.0 - 8.0.4 - 1.13.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + true + + + 8.0.0 + 8.0.0 + 8.0.4 + 1.13.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/DaprTool.Solution.AppHost/DaprTool.Solution.AppHost.csproj b/build/DaprTool.Solution.AppHost/DaprTool.Solution.AppHost.csproj index 73f9d48..58c86ee 100644 --- a/build/DaprTool.Solution.AppHost/DaprTool.Solution.AppHost.csproj +++ b/build/DaprTool.Solution.AppHost/DaprTool.Solution.AppHost.csproj @@ -7,6 +7,8 @@ DaprToolSolution.AppHost + + diff --git a/samples/Client/SampleClient.csproj b/samples/Client/SampleClient.csproj index 46d44bf..e9d7cb6 100644 --- a/samples/Client/SampleClient.csproj +++ b/samples/Client/SampleClient.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable diff --git a/samples/Interfaces/SampleInterfaces.csproj b/samples/Interfaces/SampleInterfaces.csproj index db850d8..9d36566 100644 --- a/samples/Interfaces/SampleInterfaces.csproj +++ b/samples/Interfaces/SampleInterfaces.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/samples/Service/SampleService.csproj b/samples/Service/SampleService.csproj index b81c4e0..f671077 100644 --- a/samples/Service/SampleService.csproj +++ b/samples/Service/SampleService.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable diff --git a/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs index 744d5c2..8af9ab8 100644 --- a/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs +++ b/src/BuildingBlocks/ApiExtensions/Middleware/ResultMiddleware.cs @@ -33,7 +33,7 @@ public class ResultMiddleware(RequestDelegate next) { var version = context.GetRequestedApiVersion(1).ToString(); var traceId = context.TraceIdentifier; - object returnObject = null; + object? returnObject = null; if (context.Response.StatusCode == StatusCodes.Status200OK) { diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Api/Helpers/StartupHelpers.cs b/src/IdentityServer4/src/Idsrv4.Admin.Api/Helpers/StartupHelpers.cs index 11f2020..039bd0b 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Api/Helpers/StartupHelpers.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.Api/Helpers/StartupHelpers.cs @@ -17,9 +17,7 @@ using Idsrv4.Admin.Api.Configuration.Constants; using Idsrv4.Admin.Api.Helpers.Localization; using Idsrv4.Admin.BusinessLogic.Identity.Dtos.Identity; using Idsrv4.Admin.EntityFramework.Configuration.Configuration; -using Idsrv4.Admin.EntityFramework.Configuration.MySql; using Idsrv4.Admin.EntityFramework.Configuration.PostgreSQL; -using Idsrv4.Admin.EntityFramework.Configuration.SqlServer; using Idsrv4.Admin.EntityFramework.Helpers; using Idsrv4.Admin.EntityFramework.Interfaces; using Idsrv4.Admin.AuditLogging.EntityFramework.DbContexts; diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj b/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj index 5c441b1..2eb936e 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.Api/Idsrv4.Admin.Api.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 1cc472a2-4e4b-48ce-846b-5219f71fc643 false auth-api diff --git a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging.EntityFramework/Idsrv4.Admin.AuditLogging.EntityFramework.csproj b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging.EntityFramework/Idsrv4.Admin.AuditLogging.EntityFramework.csproj index 1815f18..fb682ea 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging.EntityFramework/Idsrv4.Admin.AuditLogging.EntityFramework.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging.EntityFramework/Idsrv4.Admin.AuditLogging.EntityFramework.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Helpers/HttpContextHelpers/HttpContextHelpers.cs b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Helpers/HttpContextHelpers/HttpContextHelpers.cs index 715e7c5..f38b1b1 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Helpers/HttpContextHelpers/HttpContextHelpers.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Helpers/HttpContextHelpers/HttpContextHelpers.cs @@ -38,7 +38,7 @@ namespace Idsrv4.Admin.AuditLogging.Helpers.HttpContextHelpers IDictionary dict = new Dictionary(); foreach (var k in col) { - dict.Add(k.Key, string.Join(", ", k.Value)); + dict.Add(k.Key, string.Join(", ", k.Value.ToString())); } return dict; } diff --git a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Idsrv4.Admin.AuditLogging.csproj b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Idsrv4.Admin.AuditLogging.csproj index 91c8c84..82f6316 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Idsrv4.Admin.AuditLogging.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.AuditLogging/Idsrv4.Admin.AuditLogging.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Identity/Idsrv4.Admin.BusinessLogic.Identity.csproj b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Identity/Idsrv4.Admin.BusinessLogic.Identity.csproj index 35e3554..d7a716b 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Identity/Idsrv4.Admin.BusinessLogic.Identity.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Identity/Idsrv4.Admin.BusinessLogic.Identity.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Business Logic layer for the administration of the Asp.Net Core Identity and IdentityServer4 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Shared/Idsrv4.Admin.BusinessLogic.Shared.csproj b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Shared/Idsrv4.Admin.BusinessLogic.Shared.csproj index 58d5df1..9bfa326 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Shared/Idsrv4.Admin.BusinessLogic.Shared.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic.Shared/Idsrv4.Admin.BusinessLogic.Shared.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Shared Business Logic layer for the administration of the IdentityServer4 and Asp.Net Core Identity \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic/Idsrv4.Admin.BusinessLogic.csproj b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic/Idsrv4.Admin.BusinessLogic.csproj index 3adfca6..20ac6c5 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic/Idsrv4.Admin.BusinessLogic.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.BusinessLogic/Idsrv4.Admin.BusinessLogic.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Business Logic layer for the administration of the IdentityServer4 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/Idsrv4.Admin.EntityFramework.Configuration.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/Idsrv4.Admin.EntityFramework.Configuration.csproj index f4c8155..874a977 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/Idsrv4.Admin.EntityFramework.Configuration.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/Idsrv4.Admin.EntityFramework.Configuration.csproj @@ -1,14 +1,11 @@ - net8.0 + net9.0 Entity Framework configuration for the administration of the IdentityServer4 and Asp.Net Core Identity - - - diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/MySql/DatabaseExtensions.cs b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/MySql/DatabaseExtensions.cs deleted file mode 100644 index 4ba7e49..0000000 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/MySql/DatabaseExtensions.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System.Reflection; -using IdentityServer4.EntityFramework.Storage; -using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Idsrv4.Admin.EntityFramework.Configuration.Configuration; -using Idsrv4.Admin.EntityFramework.Interfaces; -using Idsrv4.Admin.AuditLogging.EntityFramework.DbContexts; -using Idsrv4.Admin.AuditLogging.EntityFramework.Entities; - -namespace Idsrv4.Admin.EntityFramework.Configuration.MySql; - -public static class DatabaseExtensions -{ - /// - /// Register DbContexts for IdentityServer ConfigurationStore and PersistedGrants, Identity and Logging - /// Configure the connection strings in AppSettings.json - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static void RegisterMySqlDbContexts( - this IServiceCollection services, - ConnectionStringsConfiguration connectionStrings, - DatabaseMigrationsConfiguration databaseMigrations) - where TIdentityDbContext : DbContext - where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext - where TConfigurationDbContext : DbContext, IAdminConfigurationDbContext - where TLogDbContext : DbContext, IAdminLogDbContext - where TAuditLoggingDbContext : DbContext, IAuditLoggingDbContext - where TDataProtectionDbContext : DbContext, IDataProtectionKeyContext - where TAuditLog : AuditLog - { - var migrationsAssembly = typeof(DatabaseExtensions).GetTypeInfo().Assembly.GetName().Name; - - // Config DB for identity - services.AddDbContext(options => - options.UseMySql(connectionStrings.IdentityDbConnection, - ServerVersion.AutoDetect(connectionStrings.IdentityDbConnection), - sql => sql.MigrationsAssembly(databaseMigrations.IdentityDbMigrationsAssembly ?? migrationsAssembly))); - - // Config DB from existing connection - services.AddConfigurationDbContext(options => - options.ConfigureDbContext = b => - b.UseMySql(connectionStrings.ConfigurationDbConnection, - ServerVersion.AutoDetect(connectionStrings.ConfigurationDbConnection), - sql => sql.MigrationsAssembly(databaseMigrations.ConfigurationDbMigrationsAssembly ?? - migrationsAssembly))); - - // Operational DB from existing connection - services.AddOperationalDbContext(options => options.ConfigureDbContext = b => - b.UseMySql(connectionStrings.PersistedGrantDbConnection, - ServerVersion.AutoDetect(connectionStrings.PersistedGrantDbConnection), - sql => sql.MigrationsAssembly(databaseMigrations.PersistedGrantDbMigrationsAssembly ?? - migrationsAssembly))); - - // Log DB from existing connection - services.AddDbContext(options => options.UseMySql(connectionStrings.AdminLogDbConnection, - ServerVersion.AutoDetect(connectionStrings.AdminLogDbConnection), - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.AdminLogDbMigrationsAssembly ?? - migrationsAssembly))); - - // Audit logging connection - services.AddDbContext(options => options.UseMySql( - connectionStrings.AdminAuditLogDbConnection, - ServerVersion.AutoDetect(connectionStrings.AdminAuditLogDbConnection), - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.AdminAuditLogDbMigrationsAssembly ?? - migrationsAssembly))); - - // DataProtectionKey DB from existing connection - if (!string.IsNullOrEmpty(connectionStrings.DataProtectionDbConnection)) - services.AddDbContext(options => options.UseMySql( - connectionStrings.DataProtectionDbConnection, - ServerVersion.AutoDetect(connectionStrings.DataProtectionDbConnection), - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.DataProtectionDbMigrationsAssembly ?? - migrationsAssembly))); - } - - /// - /// Register DbContexts for IdentityServer ConfigurationStore and PersistedGrants and Identity - /// Configure the connection strings in AppSettings.json - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static void RegisterMySqlDbContexts(this IServiceCollection services, - string identityConnectionString, string configurationConnectionString, - string persistedGrantConnectionString, string dataProtectionConnectionString) - where TIdentityDbContext : DbContext - where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext - where TConfigurationDbContext : DbContext, IAdminConfigurationDbContext - where TDataProtectionDbContext : DbContext, IDataProtectionKeyContext - { - var migrationsAssembly = typeof(DatabaseExtensions).GetTypeInfo().Assembly.GetName().Name; - - // Config DB for identity - services.AddDbContext(options => options.UseMySql(identityConnectionString, - ServerVersion.AutoDetect(identityConnectionString), sql => sql.MigrationsAssembly(migrationsAssembly))); - - // Config DB from existing connection - services.AddConfigurationDbContext(options => options.ConfigureDbContext = b - => b.UseMySql(configurationConnectionString, ServerVersion.AutoDetect(configurationConnectionString), - sql => sql.MigrationsAssembly(migrationsAssembly))); - - // Operational DB from existing connection - services.AddOperationalDbContext(options => options.ConfigureDbContext = b - => b.UseMySql(persistedGrantConnectionString, ServerVersion.AutoDetect(persistedGrantConnectionString), - sql => sql.MigrationsAssembly(migrationsAssembly))); - - // DataProtectionKey DB from existing connection - services.AddDbContext(options => options.UseMySql(dataProtectionConnectionString, - ServerVersion.AutoDetect(dataProtectionConnectionString), - optionsSql => optionsSql.MigrationsAssembly(migrationsAssembly))); - } -} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/SqlServer/DatabaseExtensions.cs b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/SqlServer/DatabaseExtensions.cs deleted file mode 100644 index 55b05e7..0000000 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Configuration/SqlServer/DatabaseExtensions.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Reflection; -using IdentityServer4.EntityFramework.Storage; -using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Idsrv4.Admin.EntityFramework.Configuration.Configuration; -using Idsrv4.Admin.EntityFramework.Interfaces; -using Idsrv4.Admin.AuditLogging.EntityFramework.DbContexts; -using Idsrv4.Admin.AuditLogging.EntityFramework.Entities; - -namespace Idsrv4.Admin.EntityFramework.Configuration.SqlServer; - -public static class DatabaseExtensions -{ - /// - /// Register DbContexts for IdentityServer ConfigurationStore and PersistedGrants, Identity and Logging - /// Configure the connection strings in AppSettings.json - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static void RegisterSqlServerDbContexts( - this IServiceCollection services, - ConnectionStringsConfiguration connectionStrings, - DatabaseMigrationsConfiguration databaseMigrations) - where TIdentityDbContext : DbContext - where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext - where TConfigurationDbContext : DbContext, IAdminConfigurationDbContext - where TLogDbContext : DbContext, IAdminLogDbContext - where TAuditLoggingDbContext : DbContext, IAuditLoggingDbContext - where TDataProtectionDbContext : DbContext, IDataProtectionKeyContext - where TAuditLog : AuditLog - { - var migrationsAssembly = typeof(DatabaseExtensions).GetTypeInfo().Assembly.GetName().Name; - - // Config DB for identity - services.AddDbContext(options - => options.UseSqlServer(connectionStrings.IdentityDbConnection, - sql => sql.MigrationsAssembly(databaseMigrations.IdentityDbMigrationsAssembly ?? migrationsAssembly))); - - // Config DB from existing connection - services.AddConfigurationDbContext(options => options.ConfigureDbContext = b - => b.UseSqlServer(connectionStrings.ConfigurationDbConnection, - sql => sql.MigrationsAssembly( - databaseMigrations.ConfigurationDbMigrationsAssembly ?? migrationsAssembly))); - - // Operational DB from existing connection - services.AddOperationalDbContext(options => options.ConfigureDbContext = b - => b.UseSqlServer(connectionStrings.PersistedGrantDbConnection, - sql => sql.MigrationsAssembly(databaseMigrations.PersistedGrantDbMigrationsAssembly ?? - migrationsAssembly))); - - // Log DB from existing connection - services.AddDbContext(options => options.UseSqlServer(connectionStrings.AdminLogDbConnection, - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.AdminLogDbMigrationsAssembly ?? - migrationsAssembly))); - - // Audit logging connection - services.AddDbContext(options => options.UseSqlServer( - connectionStrings.AdminAuditLogDbConnection, - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.AdminAuditLogDbMigrationsAssembly ?? - migrationsAssembly))); - - // DataProtectionKey DB from existing connection - if (!string.IsNullOrEmpty(connectionStrings.DataProtectionDbConnection)) - services.AddDbContext(options => options.UseSqlServer( - connectionStrings.DataProtectionDbConnection, - optionsSql => optionsSql.MigrationsAssembly(databaseMigrations.DataProtectionDbMigrationsAssembly ?? - migrationsAssembly))); - } - - /// - /// Register DbContexts for IdentityServer ConfigurationStore and PersistedGrants and Identity - /// Configure the connection strings in AppSettings.json - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static void RegisterSqlServerDbContexts(this IServiceCollection services, - string identityConnectionString, string configurationConnectionString, - string persistedGrantConnectionString, string dataProtectionConnectionString) - where TIdentityDbContext : DbContext - where TPersistedGrantDbContext : DbContext, IAdminPersistedGrantDbContext - where TConfigurationDbContext : DbContext, IAdminConfigurationDbContext - where TDataProtectionDbContext : DbContext, IDataProtectionKeyContext - { - var migrationsAssembly = typeof(DatabaseExtensions).GetTypeInfo().Assembly.GetName().Name; - - // Config DB for identity - services.AddDbContext(options - => options.UseSqlServer(identityConnectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); - - // Config DB from existing connection - services.AddConfigurationDbContext(options => options.ConfigureDbContext = b - => b.UseSqlServer(configurationConnectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); - - // Operational DB from existing connection - services.AddOperationalDbContext(options => options.ConfigureDbContext = b - => b.UseSqlServer(persistedGrantConnectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); - - // DataProtectionKey DB from existing connection - services.AddDbContext(options - => options.UseSqlServer(dataProtectionConnectionString, sql => sql.MigrationsAssembly(migrationsAssembly))); - } -} \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Extensions/Idsrv4.Admin.EntityFramework.Extensions.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Extensions/Idsrv4.Admin.EntityFramework.Extensions.csproj index 3124857..bb8ffe4 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Extensions/Idsrv4.Admin.EntityFramework.Extensions.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Extensions/Idsrv4.Admin.EntityFramework.Extensions.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 EntityFramework extensions for the administration of the IdentityServer4 and Asp.Net Core Identity \ No newline at end of file diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Identity/Idsrv4.Admin.EntityFramework.Identity.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Identity/Idsrv4.Admin.EntityFramework.Identity.csproj index d347866..b13656f 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Identity/Idsrv4.Admin.EntityFramework.Identity.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Identity/Idsrv4.Admin.EntityFramework.Identity.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Entity Framework layer for the administration of the Asp.Net Core Identity and IdentityServer4 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.PostgreSQL/Idsrv4.Admin.EntityFramework.PostgreSQL.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.PostgreSQL/Idsrv4.Admin.EntityFramework.PostgreSQL.csproj index fc13bee..883d84c 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.PostgreSQL/Idsrv4.Admin.EntityFramework.PostgreSQL.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.PostgreSQL/Idsrv4.Admin.EntityFramework.PostgreSQL.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Entity Framework layer for the administration of the IdentityServer4 and Asp.Net Core Identity with PostrgreSQL support diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Shared/Idsrv4.Admin.EntityFramework.Shared.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Shared/Idsrv4.Admin.EntityFramework.Shared.csproj index a3be8af..3f3e79a 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Shared/Idsrv4.Admin.EntityFramework.Shared.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework.Shared/Idsrv4.Admin.EntityFramework.Shared.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 DbContexts and Identity entities for the administration of the IdentityServer4 and Asp.Net Core Identity diff --git a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework/Idsrv4.Admin.EntityFramework.csproj b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework/Idsrv4.Admin.EntityFramework.csproj index 0f7e4dd..8c4681d 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework/Idsrv4.Admin.EntityFramework.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.EntityFramework/Idsrv4.Admin.EntityFramework.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Entity Framework layer for the administration of the IdentityServer4 diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Helpers/StartupHelpers.cs b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Helpers/StartupHelpers.cs index 19f32e2..81afe10 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Helpers/StartupHelpers.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Helpers/StartupHelpers.cs @@ -15,9 +15,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Identity.Web; using Idsrv4.Admin.EntityFramework.Configuration.Configuration; -using Idsrv4.Admin.EntityFramework.Configuration.MySql; using Idsrv4.Admin.EntityFramework.Configuration.PostgreSQL; -using Idsrv4.Admin.EntityFramework.Configuration.SqlServer; using Idsrv4.Admin.EntityFramework.Helpers; using Idsrv4.Admin.EntityFramework.Interfaces; using Idsrv4.Admin.Shared.Configuration.Authentication; diff --git a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj index f88127a..6d7ccbd 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.STS.Identity/Idsrv4.Admin.STS.Identity.csproj @@ -1,6 +1,6 @@ - + - net8.0 + net9.0 9c91d295-54c5-4d09-9bd6-fa56fb74011b false auth-sts @@ -10,9 +10,7 @@ - - diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Shared.Configuration/Idsrv4.Admin.Shared.Configuration.csproj b/src/IdentityServer4/src/Idsrv4.Admin.Shared.Configuration/Idsrv4.Admin.Shared.Configuration.csproj index 02f19e3..47709c5 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Shared.Configuration/Idsrv4.Admin.Shared.Configuration.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.Shared.Configuration/Idsrv4.Admin.Shared.Configuration.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Shared common layer for the administration of the IdentityServer4 and Asp.Net Core Identity diff --git a/src/IdentityServer4/src/Idsrv4.Admin.Shared/Idsrv4.Admin.Shared.csproj b/src/IdentityServer4/src/Idsrv4.Admin.Shared/Idsrv4.Admin.Shared.csproj index 555389b..c6f986d 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.Shared/Idsrv4.Admin.Shared.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.Shared/Idsrv4.Admin.Shared.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Shared common layer for the administration of the IdentityServer4 and Asp.Net Core Identity diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/Helpers/StartupHelpers.cs b/src/IdentityServer4/src/Idsrv4.Admin.UI/Helpers/StartupHelpers.cs index 6b743ff..32fa0ab 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.UI/Helpers/StartupHelpers.cs +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/Helpers/StartupHelpers.cs @@ -27,9 +27,7 @@ using Idsrv4.Admin.BusinessLogic.Identity.Dtos.Identity; using Idsrv4.Admin.BusinessLogic.Services; using Idsrv4.Admin.BusinessLogic.Services.Interfaces; using Idsrv4.Admin.EntityFramework.Configuration.Configuration; -using Idsrv4.Admin.EntityFramework.Configuration.MySql; using Idsrv4.Admin.EntityFramework.Configuration.PostgreSQL; -using Idsrv4.Admin.EntityFramework.Configuration.SqlServer; using Idsrv4.Admin.EntityFramework.Helpers; using Idsrv4.Admin.EntityFramework.Interfaces; using Idsrv4.Admin.EntityFramework.Repositories; diff --git a/src/IdentityServer4/src/Idsrv4.Admin.UI/Idsrv4.Admin.UI.csproj b/src/IdentityServer4/src/Idsrv4.Admin.UI/Idsrv4.Admin.UI.csproj index ed1e7e8..2844ad5 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin.UI/Idsrv4.Admin.UI.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin.UI/Idsrv4.Admin.UI.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 The package with UI for the administration of the IdentityServer4 true / @@ -92,10 +92,8 @@ - - diff --git a/src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj b/src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj index a4f06eb..b70ed9f 100644 --- a/src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj +++ b/src/IdentityServer4/src/Idsrv4.Admin/Idsrv4.Admin.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 8fe260ca-ef4c-4fa3-9364-029146f8d339 NU1803;NU1507;1701;1702;1591;8002;CS1573;NU1604; false diff --git a/src/PluggableComponents/PluggableComponents.csproj b/src/PluggableComponents/PluggableComponents.csproj index 74c72ff..3c40af9 100644 --- a/src/PluggableComponents/PluggableComponents.csproj +++ b/src/PluggableComponents/PluggableComponents.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable false diff --git a/test/DaprTool.AbstractionsTest/DataBases/JsonQueryTest.cs b/test/DaprTool.AbstractionsTest/DataBases/JsonQueryTest.cs index d9b1f44..6ffc610 100644 --- a/test/DaprTool.AbstractionsTest/DataBases/JsonQueryTest.cs +++ b/test/DaprTool.AbstractionsTest/DataBases/JsonQueryTest.cs @@ -42,7 +42,7 @@ public class JsonQueryTest(DbDependencySetupFixture fixture, ITestOutputHelper t var query = db.GetTable() .Where(x => x.CapitalAccount != null) - .JsonWhere(x => x.CapitalAccount.CapitalId == 723453551573140002); + .JsonWhere(x => x.CapitalAccount!.CapitalId == 723453551573140002); testOutputHelper.WriteLine($"查询 sql:{query}"); var row = await query.FirstOrDefaultAsync(); @@ -82,7 +82,7 @@ public class JsonQueryTest(DbDependencySetupFixture fixture, ITestOutputHelper t var query = db.GetTable() .Where(x => x.CapitalAccount != null) - .Where(x => x.CertificationInfo.JsonExtractPathText(json => json.RealName) == "张三"); + .Where(x => x.CertificationInfo.JsonExtractPathText(json => json!.RealName) == "张三"); testOutputHelper.WriteLine($"查询 sql:{query}"); var row = await query.FirstOrDefaultAsync(); -- Gitee