Просмотр исходного кода

Merge branch 'master' of http://git.fwt.com/Hotline/hotline

dss 2 лет назад
Родитель
Сommit
5c75a10f97

+ 0 - 24
src/Hotline.Api/Controllers/SysController.cs

@@ -2,7 +2,6 @@
 using Hotline.Settings;
 using Hotline.Share.Dtos.Menu;
 using Hotline.Share.Requests;
-using Identity.Admin.HttpClient;
 using MapsterMapper;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
@@ -16,7 +15,6 @@ namespace Hotline.Api.Controllers
     /// </summary>
     public class SysController : BaseController
     {
-        private readonly IIdentityClient _identityClient;
         private readonly IMapper _mapper;
         private readonly ISystemSettingRepository _systemSettingsRepository;
         private readonly ISystemSettingGroupRepository _systemSettingGroupRepository;
@@ -26,21 +24,18 @@ namespace Hotline.Api.Controllers
         /// <summary>
         /// 系统管理相关接口
         /// </summary>
-        /// <param name="identityClient"></param>
         /// <param name="mapper"></param>
         /// <param name="systemSettingsRepository"></param>
         /// <param name="systemSettingGroupRepository"></param>
         /// <param name="systemMenuRepository"></param>
         /// <param name="systemButtonRepository"></param>
         public SysController(
-            IIdentityClient identityClient,
             IMapper mapper,
             ISystemSettingRepository systemSettingsRepository,
             ISystemSettingGroupRepository systemSettingGroupRepository,
             ISystemMenuRepository systemMenuRepository,
             ISystemButtonRepository systemButtonRepository)
         {
-            _identityClient = identityClient;
             _mapper = mapper;
             _systemSettingsRepository = systemSettingsRepository;
             _systemSettingGroupRepository = systemSettingGroupRepository;
@@ -48,25 +43,6 @@ namespace Hotline.Api.Controllers
             _systemButtonRepository = systemButtonRepository;
         }
 
-        #region private
-
-        private async Task<bool> IsAccountLock(string userId)
-        {
-            var response = await _identityClient.IsAccountLockAsync(userId, HttpContext.RequestAborted);
-            if (response is null || !response.IsSuccess)
-                throw new UserFriendlyException("identity service request fail: IsAccountLockAsync");
-            return response.Result;
-        }
-
-
-        private void CheckHttpRequestSuccess(ApiResponse response, string msg)
-        {
-            if (response == null || !response.IsSuccess)
-                throw new UserFriendlyException($"identity service request failed: {msg}");
-        }
-
-        #endregion
-
         #region 系统参数
 
         /// <summary>

+ 1 - 48
src/Hotline.Api/StartupExtensions.cs

@@ -15,7 +15,6 @@ using Hotline.Permissions;
 using Hotline.Repository.SqlSugar;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Settings;
-using Identity.Admin.HttpClient;
 using Mapster;
 using MapsterMapper;
 using MediatR;
@@ -57,53 +56,7 @@ internal static class StartupExtensions
             .AddScoped<IPasswordHasher<Account>, PasswordHasher<Account>>()
             ;
 
-        var identityConfigs = configuration.GetSection(nameof(IdentityConfigs)).Get<IdentityConfigs>();
-        services.AddIdentityClient(
-            d =>
-            {
-                d.IdentityAddress = identityConfigs.IdentityUrl;
-                d.IdentityApiAddress = identityConfigs.IdentityApiUrl;
-            },
-            //new IdentityClientConfiguration(identityConfigs.IdentityUrl, identityConfigs.IdentityApiUrl),
-            d =>
-            {
-                d.ClientId = identityConfigs.ClientId;
-                d.ClientSecret = identityConfigs.ClientSecret;
-                d.ClientScope = identityConfigs.ClientScope;
-            });
-
-        //JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
-        //services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
-        //    .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, d =>
-        //    {
-        //        d.Authority = identityConfigs.IdentityUrl;
-        //        d.RequireHttpsMetadata = false;
-        //        d.TokenValidationParameters = new TokenValidationParameters
-        //        {
-        //            ValidateAudience = false
-        //        };
-        //        //d.Audience = "hotline_api";
-
-        //        d.Events = new JwtBearerEvents
-        //        {
-        //            OnMessageReceived = context =>
-        //            {
-        //                var accessToken = context.Request.Query["access_token"];
-
-        //                // If the request is for our hub...
-        //                var path = context.HttpContext.Request.Path;
-        //                if (!string.IsNullOrEmpty(accessToken) &&
-        //                    (path.StartsWithSegments("/hubs/callcenter")))
-        //                {
-        //                    // Read the token out of the query string
-        //                    context.Token = accessToken;
-        //                }
-        //                return Task.CompletedTask;
-        //            }
-        //        };
-        //    })
-        //    ;
-
+        //Authentication
         services.AddAuthenticationService(configuration);
 
         services.AddControllers(options =>

+ 33 - 1
src/Hotline.Api/appsettings.json

@@ -51,7 +51,7 @@
           "rollingInterval": "Month",
           "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}"
         }
-      } 
+      }
     ],
     "Enrich": [ "FromLogContext", "WithSpan" ]
   },
@@ -92,5 +92,37 @@
     "ClientId": "hotline_server",
     "ClientSecret": "ce2fae0e-f0f6-46d6-bd79-1f1a31dff494",
     "ClientScope": "identity_admin_api"
+  },
+  "IdentityConfiguration": {
+    "Password": {
+      "RequiredLength": 8,
+      "RequireNonAlphanumeric": true,
+      "RequireLowercase": true,
+      "RequireUppercase": true
+    },
+    "User": {
+      "RequireUniqueEmail": false
+    },
+    "SignIn": {
+      "RequireConfirmedAccount": false
+    },
+    "Lockout": {
+      "MaxFailedAccessAttempts": 5,
+      "DefaultLockoutTimeSpan": "00:10:00"
+    },
+    "Account": {
+      "DefaultPassword": "Fwkj@789"
+    },
+    "Jwt": {
+      "SecretKey": "e660d04ef1d3410798c953f5d7b8a4e1",
+      "Issuer": "hotline_server",
+      "Audience": "hotline",
+      "Scope": "hotline_api",
+      "Expired": 86400 //seceonds
+    }
+  },
+  "DatabaseConfiguration": {
+    "ApplyDbMigrations": false,
+    "ApplySeed": false
   }
 }

+ 0 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/IncomingNotificationHandler.cs

@@ -12,7 +12,6 @@ using NewRock.Sdk;
 using NewRock.Sdk.Transfer.Connect.Request;
 using XF.Domain.Cache;
 using XF.Domain.Constants;
-using static IdentityServer4.Models.IdentityResources;
 
 namespace Hotline.Application.Handlers.CallCenter.FlowControl
 {

+ 1 - 1
src/Hotline.Application/Hotline.Application.csproj

@@ -8,7 +8,7 @@
 
   <ItemGroup>
     <PackageReference Include="Dapr.AspNetCore" Version="1.9.0" />
-    <PackageReference Include="Identity.Admin.HttpClient" Version="1.0.20" />
+    <PackageReference Include="IdentityModel" Version="6.0.0" />
     <PackageReference Include="XF.Utility.AppIdentityModel" Version="1.0.2" />
   </ItemGroup>