From a1ff4230a7852c53d8201f4cffeb05904d486b8e Mon Sep 17 00:00:00 2001 From: SuhorukovAnton Date: Wed, 19 Oct 2022 14:30:14 +0300 Subject: [PATCH] fix merge --- ASC.Web.sln | 6 + .../ASC.ApiSystem/ASC.ApiSystem.csproj | 32 +++++ .../ConfigurationManagerExtension.cs | 41 ++++++ common/services/ASC.ApiSystem/GlobalUsings.cs | 105 ++++++++++++++ .../ASC.ApiSystem/Models/FindPeopleModel.cs | 32 +++++ .../Properties/launchSettings.json | 29 ++++ common/services/ASC.ApiSystem/Startup.cs | 132 ++++++++++++++++++ .../services/ASC.ApiSystem/appsettings.json | 3 + 8 files changed, 380 insertions(+) create mode 100644 common/services/ASC.ApiSystem/ASC.ApiSystem.csproj create mode 100644 common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs create mode 100644 common/services/ASC.ApiSystem/GlobalUsings.cs create mode 100644 common/services/ASC.ApiSystem/Models/FindPeopleModel.cs create mode 100644 common/services/ASC.ApiSystem/Properties/launchSettings.json create mode 100644 common/services/ASC.ApiSystem/Startup.cs create mode 100644 common/services/ASC.ApiSystem/appsettings.json diff --git a/ASC.Web.sln b/ASC.Web.sln index 02906252ee..4833d97c6e 100644 --- a/ASC.Web.sln +++ b/ASC.Web.sln @@ -89,6 +89,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.EventBus.ActiveMQ", "co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Storage.Encryption", "common\services\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj", "{76BFD0A6-3F28-4BCE-983B-9FE3FBDD966D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.ApiSystem", "common\services\ASC.ApiSystem\ASC.ApiSystem.csproj", "{EB0FC2DF-D8AC-460B-8FBE-307A7B163C6C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -251,6 +253,10 @@ Global {76BFD0A6-3F28-4BCE-983B-9FE3FBDD966D}.Debug|Any CPU.Build.0 = Debug|Any CPU {76BFD0A6-3F28-4BCE-983B-9FE3FBDD966D}.Release|Any CPU.ActiveCfg = Release|Any CPU {76BFD0A6-3F28-4BCE-983B-9FE3FBDD966D}.Release|Any CPU.Build.0 = Release|Any CPU + {EB0FC2DF-D8AC-460B-8FBE-307A7B163C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB0FC2DF-D8AC-460B-8FBE-307A7B163C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB0FC2DF-D8AC-460B-8FBE-307A7B163C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB0FC2DF-D8AC-460B-8FBE-307A7B163C6C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/common/services/ASC.ApiSystem/ASC.ApiSystem.csproj b/common/services/ASC.ApiSystem/ASC.ApiSystem.csproj new file mode 100644 index 0000000000..1211611882 --- /dev/null +++ b/common/services/ASC.ApiSystem/ASC.ApiSystem.csproj @@ -0,0 +1,32 @@ + + + + net6.0 + ASC.ApiSystem + Ascensio System SIA + ASC.ApiSystem + (c) Ascensio System SIA. All rights reserved + false + false + false + NU1701 + + + + + + + + + + + + + + + + + + + + diff --git a/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs b/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs new file mode 100644 index 0000000000..570c637702 --- /dev/null +++ b/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs @@ -0,0 +1,41 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +namespace ASC.ApiSystem; + +public static class ConfigurationManagerExtension +{ + public static ConfigurationManager AddApiSystemConfiguration(this ConfigurationManager config, IHostEnvironment env) + { + config + .AddJsonFile($"apisystem.json") + .AddJsonFile($"apisystem.{env.EnvironmentName}.json", true) + .AddJsonFile("notify.json") + .AddJsonFile($"notify.{env.EnvironmentName}.json", true); + + return config; + } +} diff --git a/common/services/ASC.ApiSystem/GlobalUsings.cs b/common/services/ASC.ApiSystem/GlobalUsings.cs new file mode 100644 index 0000000000..16d26636ee --- /dev/null +++ b/common/services/ASC.ApiSystem/GlobalUsings.cs @@ -0,0 +1,105 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +global using System; +global using System.Collections.Generic; +global using System.ComponentModel.DataAnnotations; +global using System.Diagnostics; +global using System.Globalization; +global using System.IO; +global using System.Linq; +global using System.Net; +global using System.Net.Http; +global using System.Net.Http.Headers; +global using System.Security.Authentication; +global using System.Security.Claims; +global using System.Security.Cryptography; +global using System.Text; +global using System.Text.Encodings.Web; +global using System.Text.Json.Serialization; +global using System.Text.RegularExpressions; +global using System.Threading.Tasks; +global using System.Web; +global using System.Web.Http.Filters; + +global using ASC.Api.Core; +global using ASC.Api.Core.Auth; +global using ASC.Api.Core.Core; +global using ASC.Api.Core.Extensions; +global using ASC.Api.Core.Middleware; +global using ASC.ApiSystem; +global using ASC.ApiSystem.Classes; +global using ASC.ApiSystem.Interfaces; +global using ASC.ApiSystem.Models; +global using ASC.Common; +global using ASC.Common.Caching; +global using ASC.Common.Logging; +global using ASC.Common.Security.Authorizing; +global using ASC.Common.Utils; +global using ASC.Core; +global using ASC.Core.Billing; +global using ASC.Core.Common.EF; +global using ASC.Core.Common.EF.Context; +global using ASC.Core.Common.Hosting; +global using ASC.Core.Common.Security; +global using ASC.Core.Common.Settings; +global using ASC.Core.Tenants; +global using ASC.Core.Users; +global using ASC.EventBus.Extensions.Logger; +global using ASC.Feed.Context; +global using ASC.MessagingSystem.EF.Context; +global using ASC.Security.Cryptography; +global using ASC.Web.Core.Helpers; +global using ASC.Web.Core.PublicResources; +global using ASC.Web.Core.Users; +global using ASC.Web.Core.Utility; +global using ASC.Web.Core.Utility.Settings; +global using ASC.Web.Studio.Utility; +global using ASC.Webhooks.Core; +global using ASC.Webhooks.Core.EF.Context; + +global using Autofac; + +global using Microsoft.AspNetCore.Authentication; +global using Microsoft.AspNetCore.Authorization; +global using Microsoft.AspNetCore.Builder; +global using Microsoft.AspNetCore.Hosting; +global using Microsoft.AspNetCore.Http; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.AspNetCore.Routing; +global using Microsoft.AspNetCore.WebUtilities; +global using Microsoft.Extensions.Caching.Memory; +global using Microsoft.Extensions.Configuration; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.DependencyInjection.Extensions; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Hosting.WindowsServices; +global using Microsoft.Extensions.Logging; +global using Microsoft.Extensions.Options; + +global using Newtonsoft.Json.Linq; + +global using NLog; \ No newline at end of file diff --git a/common/services/ASC.ApiSystem/Models/FindPeopleModel.cs b/common/services/ASC.ApiSystem/Models/FindPeopleModel.cs new file mode 100644 index 0000000000..9f7bbd9545 --- /dev/null +++ b/common/services/ASC.ApiSystem/Models/FindPeopleModel.cs @@ -0,0 +1,32 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +namespace ASC.ApiSystem.Models; + +public class FindPeopleModel +{ + public IEnumerable UserIds { get; set; } +} diff --git a/common/services/ASC.ApiSystem/Properties/launchSettings.json b/common/services/ASC.ApiSystem/Properties/launchSettings.json new file mode 100644 index 0000000000..ef70f2c7c2 --- /dev/null +++ b/common/services/ASC.ApiSystem/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "profiles": { + "Kestrel WebServer": { + "commandName": "Project", + "launchBrowser": false, + "launchUrl": "http://localhost:5010/portal/test", + "environmentVariables": { + "$STORAGE_ROOT": "../../../Data", + "log__name": "apisystem", + "log__dir": "../../../Logs", + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5010" + } + }, + "WSL 2 : Ubuntu 20.04": { + "commandName": "WSL2", + "launchBrowser": false, + "launchUrl": "http://localhost:5010/portal/test", + "environmentVariables": { + "$STORAGE_ROOT": "../../../Data", + "log__name": "apisystem", + "log__dir": "../../../Logs", + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5010" + }, + "distributionName": "Ubuntu-20.04" + } + } +} diff --git a/common/services/ASC.ApiSystem/Startup.cs b/common/services/ASC.ApiSystem/Startup.cs new file mode 100644 index 0000000000..57858120b6 --- /dev/null +++ b/common/services/ASC.ApiSystem/Startup.cs @@ -0,0 +1,132 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + +namespace ASC.ApiSystem; + +public class Startup +{ + + private readonly IConfiguration _configuration; + private readonly IHostEnvironment _hostEnvironment; + private readonly DIHelper _diHelper; + + public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment) + { + _configuration = configuration; + _hostEnvironment = hostEnvironment; + _diHelper = new DIHelper(); + } + + public void ConfigureServices(IServiceCollection services) + { + services.AddCustomHealthCheck(_configuration); + services.AddHttpContextAccessor(); + services.AddMemoryCache(); + services.AddHttpClient(); + + services.AddScoped(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + services.AddBaseDbContextPool(); + + services.AddSession(); + + _diHelper.Configure(services); + + Action jsonOptions = options => + { + options.JsonSerializerOptions.WriteIndented = false; + options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + options.JsonSerializerOptions.Converters.Add(new ApiDateTimeConverter()); + }; + + services.AddControllers() + .AddXmlSerializerFormatters() + .AddJsonOptions(jsonOptions); + + services.AddSingleton(jsonOptions); + + _diHelper.AddControllers(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + _diHelper.TryAdd(); + + services.AddDistributedCache(_configuration); + services.AddEventBus(_configuration); + services.AddDistributedTaskQueue(); + services.AddCacheNotify(_configuration); + + services.RegisterFeature(); + + _diHelper.TryAdd(typeof(IWebhookPublisher), typeof(WebhookPublisher)); + + _diHelper.RegisterProducts(_configuration, _hostEnvironment.ContentRootPath); + + services.AddAutoMapper(BaseStartup.GetAutoMapperProfileAssemblies()); + + if (!_hostEnvironment.IsDevelopment()) + { + services.AddStartupTask() + .TryAddSingleton(services); + } + + services.AddAuthentication() + .AddScheme("auth:allowskip:default", _ => { }) + .AddScheme("auth:allowskip:registerportal", _ => { }); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseRouting(); + + app.UseAuthentication(); + + app.UseAuthorization(); + + app.UseCultureMiddleware(); + + app.UseEndpoints(endpoints => + { + endpoints.MapCustom(); + }); + } +} diff --git a/common/services/ASC.ApiSystem/appsettings.json b/common/services/ASC.ApiSystem/appsettings.json new file mode 100644 index 0000000000..9bf702e310 --- /dev/null +++ b/common/services/ASC.ApiSystem/appsettings.json @@ -0,0 +1,3 @@ +{ + "pathToConf": "..\\..\\..\\config" +}