diff --git a/Directory.Packages.props b/Directory.Packages.props index 59d95c697..82b823da1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,8 +3,8 @@ 8.3.5 2.15.2 3.3.5 - 9.2.0 - 9.2.0 + 9.2.1 + 9.2.1 9.0.4 9.0.4 9.0.4 @@ -12,7 +12,7 @@ - + diff --git a/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN/Abp/AspNetCore/WebClientInfo/RequestForwardedHeaderWebClientInfoProvider.cs b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN/Abp/AspNetCore/WebClientInfo/RequestForwardedHeaderWebClientInfoProvider.cs index c07c13703..d30e700c0 100644 --- a/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN/Abp/AspNetCore/WebClientInfo/RequestForwardedHeaderWebClientInfoProvider.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.HttpOverrides/LINGYUN/Abp/AspNetCore/WebClientInfo/RequestForwardedHeaderWebClientInfoProvider.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; +using MyCSharp.HttpUserAgentParser.Providers; using System; using System.Linq; using Volo.Abp.AspNetCore.WebClientInfo; @@ -16,8 +17,9 @@ public class RequestForwardedHeaderWebClientInfoProvider : HttpContextWebClientI public RequestForwardedHeaderWebClientInfoProvider( ILogger logger, IOptions options, - IHttpContextAccessor httpContextAccessor) - : base(logger, httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + IHttpUserAgentParserProvider httpUserAgentParser) + : base(logger, httpContextAccessor, httpUserAgentParser) { Options = options.Value; } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs index 54fc37871..8d434ad71 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs @@ -1,6 +1,7 @@ -using DeviceDetectorNET; -using LINGYUN.Abp.IP.Location; +using LINGYUN.Abp.IP.Location; using Microsoft.Extensions.Options; +using MyCSharp.HttpUserAgentParser; +using MyCSharp.HttpUserAgentParser.Providers; using System; using System.Threading.Tasks; using Volo.Abp.AspNetCore.WebClientInfo; @@ -11,15 +12,18 @@ public class HttpContextDeviceInfoProvider : IDeviceInfoProvider, ITransientDepe { protected IIPLocationResolver IPLocationResolver { get; } protected IWebClientInfoProvider WebClientInfoProvider { get; } + protected IHttpUserAgentParserProvider HttpUserAgentParser { get; } protected AbpIdentitySessionAspNetCoreOptions Options { get; } public HttpContextDeviceInfoProvider( IIPLocationResolver iPLocationResolver, IWebClientInfoProvider webClientInfoProvider, + IHttpUserAgentParserProvider httpUserAgentParserProvider, IOptions options) { IPLocationResolver = iPLocationResolver; WebClientInfoProvider = webClientInfoProvider; + HttpUserAgentParser = httpUserAgentParserProvider; Options = options.Value; } @@ -27,7 +31,7 @@ public class HttpContextDeviceInfoProvider : IDeviceInfoProvider, ITransientDepe public async virtual Task GetDeviceInfoAsync() { - var deviceInfo = BrowserDeviceInfo.Parse(WebClientInfoProvider.BrowserInfo); + var deviceInfo = BrowserDeviceInfo.Parse(HttpUserAgentParser, WebClientInfoProvider.BrowserInfo); var ipAddress = WebClientInfoProvider.ClientIpAddress; var ipRegion = ""; if (!ipAddress.IsNullOrWhiteSpace()) @@ -66,44 +70,30 @@ public class HttpContextDeviceInfoProvider : IDeviceInfoProvider, ITransientDepe Description = description; } - public static BrowserDeviceInfo Parse(string browserInfo) + public static BrowserDeviceInfo Parse(IHttpUserAgentParserProvider httpUserAgentParserProvider, string browserInfo) { string device = null; string deviceInfo = null; if (!browserInfo.IsNullOrWhiteSpace()) { - var deviceDetector = new DeviceDetector(browserInfo); - deviceDetector.Parse(); - if (deviceDetector.IsParsed()) + var httpUserAgentInformation = httpUserAgentParserProvider.Parse(browserInfo); + if (!httpUserAgentInformation.MobileDeviceType.IsNullOrWhiteSpace()) { - var osInfo = deviceDetector.GetOs(); - if (deviceDetector.IsMobile()) - { - // IdentitySessionDevices.Mobile - device = osInfo.Success ? osInfo.Match.Name : "Mobile"; - } - else if (deviceDetector.IsBrowser()) - { - // IdentitySessionDevices.Web - device = "Web"; - } - else if (deviceDetector.IsDesktop()) - { - // TODO: PC - device = "Desktop"; - } - - if (osInfo.Success) - { - deviceInfo = osInfo.Match.Name + " " + osInfo.Match.Version; - } - - var clientInfo = deviceDetector.GetClient(); - if (clientInfo.Success) - { - deviceInfo = deviceInfo.IsNullOrWhiteSpace() ? clientInfo.Match.Name : deviceInfo + " " + clientInfo.Match.Name; - } + device = httpUserAgentInformation.MobileDeviceType; + } + else if (!httpUserAgentInformation.Name.IsNullOrWhiteSpace()) + { + device = "Web"; } + else + { + device = "OAuth"; + } + deviceInfo = httpUserAgentInformation.Type switch + { + HttpUserAgentType.Browser or HttpUserAgentType.Robot => (httpUserAgentInformation.Platform.HasValue ? httpUserAgentInformation.Platform.Value.Name + " " : string.Empty) + httpUserAgentInformation.Name, + _ => httpUserAgentInformation.UserAgent, + }; } return new BrowserDeviceInfo(device, deviceInfo); } diff --git a/common.props b/common.props index 137a91007..11a1acd78 100644 --- a/common.props +++ b/common.props @@ -1,12 +1,12 @@ latest - 9.2.0 + 9.2.1 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin $(SolutionDir)LocalNuget - 9.2.0 + 9.2.1 MIT git https://github.com/colinin/abp-next-admin diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Dockerfile b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Dockerfile index 0ff1ca1da..5af559ba3 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Dockerfile +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 LABEL maintainer="colin.in@foxmail.com" WORKDIR /app diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Program.cs b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Program.cs index 92e111d1e..89255d823 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Program.cs +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/Program.cs @@ -7,11 +7,13 @@ .AddYarpJson() .ConfigureAppConfiguration((context, config) => { - var configuration = config.Build(); - var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; - if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) + var agileConfig = context.Configuration.GetSection("AgileConfig");//IsEnabled + if (agileConfig.Exists()) { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + if (agileConfig.GetValue("IsEnabled", false)) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); + } } }) .UseSerilog((context, provider, config) =>