diff --git a/common/ASC.Api.Core/Core/BaseStartup.cs b/common/ASC.Api.Core/Core/BaseStartup.cs index 11f27a5646..192f8a912e 100644 --- a/common/ASC.Api.Core/Core/BaseStartup.cs +++ b/common/ASC.Api.Core/Core/BaseStartup.cs @@ -226,7 +226,7 @@ public abstract class BaseStartup } } - private IEnumerable GetAutoMapperProfileAssemblies() + protected IEnumerable GetAutoMapperProfileAssemblies() { return AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.StartsWith("ASC.")); } diff --git a/common/ASC.Core.Common/Data/DbTenantService.cs b/common/ASC.Core.Common/Data/DbTenantService.cs index 8b8d0b1f81..25ee109840 100644 --- a/common/ASC.Core.Common/Data/DbTenantService.cs +++ b/common/ASC.Core.Common/Data/DbTenantService.cs @@ -218,7 +218,7 @@ public class DbTenantService : ITenantService tenant.LastModified = DateTime.UtcNow; var dbTenant = _mapper.Map(tenant); - + dbTenant.Id = 0; dbTenant = tenantDbContext.Tenants.Add(dbTenant).Entity; tenantDbContext.SaveChanges(); tenant.Id = dbTenant.Id; @@ -235,7 +235,7 @@ public class DbTenantService : ITenantService dbTenant.MappedDomain = !string.IsNullOrEmpty(tenant.MappedDomain) ? tenant.MappedDomain.ToLowerInvariant() : null; dbTenant.Version = tenant.Version; dbTenant.VersionChanged = tenant.VersionChanged; - dbTenant.Name = tenant.Name ?? tenant.Alias; + dbTenant.Name = tenant.Name ?? ""; dbTenant.Language = tenant.Language; dbTenant.TimeZone = tenant.TimeZone; dbTenant.TrustedDomainsRaw = tenant.GetTrustedDomains(); diff --git a/common/ASC.Core.Common/EF/Model/Tenant/DbTenant.cs b/common/ASC.Core.Common/EF/Model/Tenant/DbTenant.cs index 62d68bdcb6..5440596adb 100644 --- a/common/ASC.Core.Common/EF/Model/Tenant/DbTenant.cs +++ b/common/ASC.Core.Common/EF/Model/Tenant/DbTenant.cs @@ -69,7 +69,7 @@ public class DbTenant : IMapFrom .ForMember(dest => dest.TrustedDomainsRaw, opt => opt.MapFrom(dest => dest.GetTrustedDomains())) .ForMember(dest => dest.Alias, opt => opt.MapFrom(dest => dest.Alias.ToLowerInvariant())) .ForMember(dest => dest.LastModified, opt => opt.MapFrom(dest => DateTime.UtcNow)) - .ForMember(dest => dest.Name, opt => opt.MapFrom(dest => dest.Name ?? dest.Alias)) + .ForMember(dest => dest.Name, opt => opt.MapFrom(dest => dest.Name ?? "")) .ForMember(dest => dest.MappedDomain, opt => opt.MapFrom(dest => !string.IsNullOrEmpty(dest.MappedDomain) ? dest.MappedDomain.ToLowerInvariant() : null)); } diff --git a/common/ASC.Core.Common/HostedSolution.cs b/common/ASC.Core.Common/HostedSolution.cs index 55c6d2a97f..08fb5c0fdc 100644 --- a/common/ASC.Core.Common/HostedSolution.cs +++ b/common/ASC.Core.Common/HostedSolution.cs @@ -42,9 +42,33 @@ public class HostedSolution internal DbSettingsManager SettingsManager { get; set; } internal CoreSettings CoreSettings { get; set; } - public string Region { get; set; } + public string Region { get; private set; } - public HostedSolution() { } + public HostedSolution(ITenantService tenantService, + IUserService userService, + IQuotaService quotaService, + ITariffService tariffService, + UserFormatter userFormatter, + TenantManager clientTenantManager, + TenantUtil tenantUtil, + DbSettingsManager settingsManager, + CoreSettings coreSettings) + { + TenantService = tenantService; + UserService = userService; + QuotaService = quotaService; + TariffService = tariffService; + UserFormatter = userFormatter; + ClientTenantManager = clientTenantManager; + TenantUtil = tenantUtil; + SettingsManager = settingsManager; + CoreSettings = coreSettings; + } + + public void Init(string region) + { + Region = region; + } public List GetTenants(DateTime from) { diff --git a/common/services/ASC.ApiSystem/Classes/AuthHandler.cs b/common/services/ASC.ApiSystem/Classes/AuthHandler.cs index 800352b2e4..68b74c7653 100644 --- a/common/services/ASC.ApiSystem/Classes/AuthHandler.cs +++ b/common/services/ASC.ApiSystem/Classes/AuthHandler.cs @@ -25,6 +25,10 @@ // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode +using System.Threading; + +using ASC.Common.Security.Authorizing; + namespace ASC.ApiSystem.Classes; [Scope] @@ -68,8 +72,8 @@ public class AuthHandler : AuthenticationHandler { if (Convert.ToBoolean(Configuration[Scheme.Name] ?? "false")) { - Log.LogDebug("Auth for {0} skipped", Scheme.Name); - + Log.LogDebug("Auth for {0} skipped", Scheme.Name); + Authenticate(); return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name))); } @@ -95,7 +99,7 @@ public class AuthHandler : AuthenticationHandler if (splitted.Length < 3) { Log.LogDebug("Auth failed: invalid token {0}.", header); - + return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized)))); } @@ -147,7 +151,23 @@ public class AuthHandler : AuthenticationHandler var identity = new ClaimsIdentity(Scheme.Name); Log.LogInformation("Auth success {0}", Scheme.Name); - if (HttpContextAccessor?.HttpContext != null) HttpContextAccessor.HttpContext.User = new CustomClaimsPrincipal(new ClaimsIdentity(Scheme.Name), identity); + if (HttpContextAccessor?.HttpContext != null) HttpContextAccessor.HttpContext.User = new CustomClaimsPrincipal(new ClaimsIdentity(Scheme.Name), identity); + + Authenticate(); return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name))); + } + + private void Authenticate() + { + var account = Core.Configuration.Constants.SystemAccounts.FirstOrDefault(a => a.ID == Core.Configuration.Constants.CoreSystem.ID); + + var claims = new List + { + new Claim(ClaimTypes.Sid, account.ID.ToString()), + new Claim(ClaimTypes.Name, account.Name), + new Claim(ClaimTypes.Role, Role.System) + }; + + HttpContextAccessor.HttpContext.User = new CustomClaimsPrincipal(new ClaimsIdentity(account, claims), account); } } diff --git a/common/services/ASC.ApiSystem/Classes/CommonMethods.cs b/common/services/ASC.ApiSystem/Classes/CommonMethods.cs index f0dfe9d16a..8cc18b3f8b 100644 --- a/common/services/ASC.ApiSystem/Classes/CommonMethods.cs +++ b/common/services/ASC.ApiSystem/Classes/CommonMethods.cs @@ -52,6 +52,8 @@ +using ASC.Web.Core.PublicResources; + namespace ASC.ApiSystem.Controllers; [Scope] @@ -92,7 +94,7 @@ public class CommonMethods EmailValidationKeyProvider emailValidationKeyProvider, TimeZoneConverter timeZoneConverter, CommonConstants commonConstants, IMemoryCache memoryCache, - IOptionsSnapshot hostedSolutionOptions, + HostedSolution hostedSolution, CoreBaseSettings coreBaseSettings, TenantManager tenantManager, IHttpClientFactory clientFactory) @@ -121,7 +123,8 @@ public class CommonMethods ClientFactory = clientFactory; - HostedSolution = hostedSolutionOptions.Get(CommonConstants.BaseDbConnKeyString); + HostedSolution = hostedSolution; + HostedSolution.Init(CommonConstants.BaseDbConnKeyString); } @@ -134,7 +137,7 @@ public class CommonMethods hostedRegion = t.HostedRegion, industry = t.Industry, language = t.Language, - name = t.Name, + name = t.Name == "" ? Resource.PortalName : t.Name, ownerId = t.OwnerId, partnerId = t.PartnerId, paymentId = t.PaymentId, @@ -172,6 +175,7 @@ public class CommonMethods var request = new HttpRequestMessage(); request.Method = HttpMethod.Post; + request.RequestUri = new Uri(url); request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/x-www-form-urlencoded")); try diff --git a/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs b/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs new file mode 100644 index 0000000000..3f4d55efbc --- /dev/null +++ b/common/services/ASC.ApiSystem/ConfigurationManagerExtension.cs @@ -0,0 +1,43 @@ +// (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 + +using Microsoft.Extensions.Hosting; + +namespace ASC.ApiSystem; + +public static class ConfigurationManagerExtension +{ + public static ConfigurationManager AddApiSystemConfiguration( + this ConfigurationManager config, + IHostEnvironment env) + { + config.AddJsonFile($"appsettings.services.json", true) + .AddJsonFile("notify.json") + .AddJsonFile($"notify.{env.EnvironmentName}.json", true); + + return config; + } +} diff --git a/common/services/ASC.ApiSystem/Controllers/CalDavController.cs b/common/services/ASC.ApiSystem/Controllers/CalDavController.cs index 74205b47cd..8abcd56207 100644 --- a/common/services/ASC.ApiSystem/Controllers/CalDavController.cs +++ b/common/services/ASC.ApiSystem/Controllers/CalDavController.cs @@ -124,7 +124,7 @@ public class CalDavController : ControllerBase } [HttpGet("caldav_delete_event")] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult CaldavDeleteEvent(string eventInfo) { if (!GetTenant(eventInfo, out var tenant, out var error)) @@ -153,7 +153,7 @@ public class CalDavController : ControllerBase } [HttpPost("is_caldav_authenticated")] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult IsCaldavAuthenticated(UserPassword userPassword) { if (userPassword == null || string.IsNullOrEmpty(userPassword.User) || string.IsNullOrEmpty(userPassword.Password)) diff --git a/common/services/ASC.ApiSystem/Controllers/PeopleController.cs b/common/services/ASC.ApiSystem/Controllers/PeopleController.cs index f0a7de5a53..c42b604bd6 100644 --- a/common/services/ASC.ApiSystem/Controllers/PeopleController.cs +++ b/common/services/ASC.ApiSystem/Controllers/PeopleController.cs @@ -58,7 +58,7 @@ public class PeopleController : ControllerBase public PeopleController( ILogger option, - IOptionsSnapshot hostedSolutionOptions, + HostedSolution hostedSolution, UserFormatter userFormatter, ICache cache, CoreSettings coreSettings, @@ -66,7 +66,7 @@ public class PeopleController : ControllerBase IHttpContextAccessor httpContextAccessor) { Log = option; - HostedSolution = hostedSolutionOptions.Value; + HostedSolution = hostedSolution; UserFormatter = userFormatter; Cache = cache; CoreSettings = coreSettings; @@ -91,10 +91,10 @@ public class PeopleController : ControllerBase [HttpPost("find")] [AllowCrossSiteJson] - public IActionResult Find(IEnumerable userIds) + public IActionResult Find(FindPeopleModel model) { var sw = Stopwatch.StartNew(); - userIds = userIds ?? new List(); + var userIds = model.UserIds ?? new List(); var users = HostedSolution.FindUsers(userIds); diff --git a/common/services/ASC.ApiSystem/Controllers/PortalController.cs b/common/services/ASC.ApiSystem/Controllers/PortalController.cs index d2aaa8b986..be12282c62 100644 --- a/common/services/ASC.ApiSystem/Controllers/PortalController.cs +++ b/common/services/ASC.ApiSystem/Controllers/PortalController.cs @@ -55,7 +55,7 @@ public class PortalController : ControllerBase SettingsManager settingsManager, ApiSystemHelper apiSystemHelper, CommonMethods commonMethods, - IOptionsSnapshot hostedSolutionOptions, + HostedSolution hostedSolution, CoreSettings coreSettings, TenantDomainValidator tenantDomainValidator, UserFormatter userFormatter, @@ -72,7 +72,7 @@ public class PortalController : ControllerBase SettingsManager = settingsManager; ApiSystemHelper = apiSystemHelper; CommonMethods = commonMethods; - HostedSolution = hostedSolutionOptions.Value; + HostedSolution = hostedSolution; CoreSettings = coreSettings; TenantDomainValidator = tenantDomainValidator; UserFormatter = userFormatter; @@ -100,8 +100,9 @@ public class PortalController : ControllerBase #region API methods [HttpPost("register")] - [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip.registerportal")] + [AllowCrossSiteJson] + [AllowAnonymous] + [Authorize(AuthenticationSchemes = "auth:allowskip:registerportal")] public Task RegisterAsync(TenantModel model) { if (model == null) @@ -207,7 +208,7 @@ public class PortalController : ControllerBase var info = new TenantRegistrationInfo { - Name = Configuration["web:portal-name"] ?? "Cloud Office Applications", + Name = Configuration["web:portal-name"] ?? "", Address = model.PortalName, Culture = lang, FirstName = model.FirstName, @@ -336,7 +337,7 @@ public class PortalController : ControllerBase [HttpDelete("remove")] [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult Remove([FromQuery] TenantModel model) { if (!CommonMethods.GetTenant(model, out var tenant)) @@ -371,7 +372,7 @@ public class PortalController : ControllerBase [HttpPut("status")] [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult ChangeStatus(TenantModel model) { if (!CommonMethods.GetTenant(model, out var tenant)) @@ -446,7 +447,7 @@ public class PortalController : ControllerBase [HttpGet("get")] [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult GetPortals([FromQuery] TenantModel model) { try diff --git a/common/services/ASC.ApiSystem/Controllers/SettingsController.cs b/common/services/ASC.ApiSystem/Controllers/SettingsController.cs index 4828f6570c..1e1496ad3b 100644 --- a/common/services/ASC.ApiSystem/Controllers/SettingsController.cs +++ b/common/services/ASC.ApiSystem/Controllers/SettingsController.cs @@ -86,7 +86,7 @@ public class SettingsController : ControllerBase #region API methods [HttpGet("get")] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult GetSettings([FromQuery] SettingsModel model) { if (!GetTenant(model, out var tenantId, out var error)) @@ -112,7 +112,7 @@ public class SettingsController : ControllerBase } [HttpPost("save")] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult SaveSettings([FromBody] SettingsModel model) { if (!GetTenant(model, out var tenantId, out var error)) diff --git a/common/services/ASC.ApiSystem/Controllers/TariffController.cs b/common/services/ASC.ApiSystem/Controllers/TariffController.cs index e78d8d3b0b..83cc67093e 100644 --- a/common/services/ASC.ApiSystem/Controllers/TariffController.cs +++ b/common/services/ASC.ApiSystem/Controllers/TariffController.cs @@ -61,12 +61,12 @@ public class TariffController : ControllerBase private ILogger Log { get; } public TariffController( CommonMethods commonMethods, - IOptionsSnapshot hostedSolutionOptions, + HostedSolution hostedSolution, ILogger option ) { CommonMethods = commonMethods; - HostedSolution = hostedSolutionOptions.Value; + HostedSolution = hostedSolution; Log = option; } @@ -87,7 +87,7 @@ public class TariffController : ControllerBase [HttpPut("set")] [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult SetTariff(TariffModel model) { if (!CommonMethods.GetTenant(model, out var tenant)) @@ -136,12 +136,12 @@ public class TariffController : ControllerBase quota.MaxFileSize = model.MaxFileSize; } - HostedSolution.SaveTenantQuota(quota); + HostedSolution.SaveTenantQuota(quota); var tariff = new Tariff { QuotaId = quota.Tenant, - DueDate = model.DueDate != default ? model.DueDate : DateTime.MaxValue, + DueDate = model.DueDate != default ? model.DueDate : DateTime.MaxValue.AddSeconds(-1), }; HostedSolution.SetTariff(tenant.Id, tariff); @@ -151,7 +151,7 @@ public class TariffController : ControllerBase [HttpGet("get")] [AllowCrossSiteJson] - [Authorize(AuthenticationSchemes = "auth.allowskip")] + [Authorize(AuthenticationSchemes = "auth:allowskip")] public IActionResult GetTariff([FromQuery] TariffModel model) { if (!CommonMethods.GetTenant(model, out var tenant)) 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/Program.cs b/common/services/ASC.ApiSystem/Program.cs index c209c1f3e9..cbef54bd0e 100644 --- a/common/services/ASC.ApiSystem/Program.cs +++ b/common/services/ASC.ApiSystem/Program.cs @@ -50,6 +50,8 @@ */ +using ASC.ApiSystem; + var options = new WebApplicationOptions { Args = args, @@ -58,34 +60,14 @@ var options = new WebApplicationOptions var builder = WebApplication.CreateBuilder(options); -builder.Host.ConfigureDefault(args, (hostContext, config, env, path) => -{ - config.AddJsonFile($"appsettings.services.json", true) - .AddJsonFile("notify.json") - .AddJsonFile($"notify.{env.EnvironmentName}.json", true); -}, -(hostContext, services, diHelper) => -{ - diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath); +builder.Host.ConfigureDefault(); - diHelper.TryAdd(); - diHelper.AddControllers(); +builder.Configuration.AddDefaultConfiguration(builder.Environment) + .AddApiSystemConfiguration(builder.Environment) + .AddEnvironmentVariables() + .AddCommandLine(args); - services.AddControllers() - .AddJsonOptions(options => - { - options.JsonSerializerOptions.WriteIndented = false; - options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; - }); - - services.AddAutoMapper(Assembly.GetAssembly(typeof(MappingProfile))); - - services.AddAuthentication() - .AddScheme("auth.allowskip", _ => { }) - .AddScheme("auth.allowskip.registerportal", _ => { }); -}); - -var startup = new BaseWorkerStartup(builder.Configuration); +var startup = new Startup(builder.Configuration, builder.Environment); startup.ConfigureServices(builder.Services); @@ -96,6 +78,6 @@ builder.Host.ConfigureContainer((context, builder) => var app = builder.Build(); -startup.Configure(app); +startup.Configure(app, app.Environment); await app.RunAsync(); diff --git a/common/services/ASC.ApiSystem/Startup.cs b/common/services/ASC.ApiSystem/Startup.cs new file mode 100644 index 0000000000..e901c0b3d3 --- /dev/null +++ b/common/services/ASC.ApiSystem/Startup.cs @@ -0,0 +1,53 @@ +// (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 + +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace ASC.ApiSystem; + +public class Startup : BaseStartup +{ + public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment) : base (configuration, hostEnvironment) + { + } + + public override void ConfigureServices(IServiceCollection services) + { + base.ConfigureServices(services); + + DIHelper.TryAdd(); + + services.AddAuthentication() + .AddScheme("auth:allowskip", _ => { }) + .AddScheme("auth:allowskip:registerportal", _ => { }); + } + + public override void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + base.Configure(app, env); + } +} diff --git a/web/ASC.Web.Api/Api/Settings/GreetingSettingsController.cs b/web/ASC.Web.Api/Api/Settings/GreetingSettingsController.cs index fdd8f31f37..930e11d6a0 100644 --- a/web/ASC.Web.Api/Api/Settings/GreetingSettingsController.cs +++ b/web/ASC.Web.Api/Api/Settings/GreetingSettingsController.cs @@ -54,7 +54,7 @@ public class GreetingSettingsController : BaseSettingsController [HttpGet("greetingsettings")] public ContentResult GetGreetingSettings() { - return new ContentResult { Content = Tenant.Name }; + return new ContentResult { Content = Tenant.Name == "" ? Resource.PortalName : Tenant.Name }; } [HttpPost("greetingsettings")] @@ -79,7 +79,7 @@ public class GreetingSettingsController : BaseSettingsController return new ContentResult { - Content = Tenant.Name + Content = Tenant.Name == "" ? Resource.PortalName : Tenant.Name }; } } diff --git a/web/ASC.Web.Api/Api/Settings/SettingsController.cs b/web/ASC.Web.Api/Api/Settings/SettingsController.cs index 8cc1a77cd1..0637eca01b 100644 --- a/web/ASC.Web.Api/Api/Settings/SettingsController.cs +++ b/web/ASC.Web.Api/Api/Settings/SettingsController.cs @@ -145,7 +145,7 @@ public class SettingsController : BaseSettingsController var settings = new SettingsDto { Culture = Tenant.GetCulture().ToString(), - GreetingSettings = Tenant.Name, + GreetingSettings = Tenant.Name == "" ? Resource.PortalName : Tenant.Name, Personal = _coreBaseSettings.Personal, DocSpace = !_coreBaseSettings.DisableDocSpace, Version = _configuration["version:number"] ?? "", diff --git a/web/ASC.Web.Core/Notify/NotifyConfiguration.cs b/web/ASC.Web.Core/Notify/NotifyConfiguration.cs index d4c129f17a..4be950c53d 100644 --- a/web/ASC.Web.Core/Notify/NotifyConfiguration.cs +++ b/web/ASC.Web.Core/Notify/NotifyConfiguration.cs @@ -356,7 +356,7 @@ public class NotifyTransferRequest : INotifyEngineAction request.Arguments.Add(new TagValue(CommonTags.HelpLink, _commonLinkUtility.GetHelpLink(_settingsManager, _additionalWhiteLabelSettingsHelper, false))); request.Arguments.Add(new TagValue(CommonTags.LetterLogoText, logoText)); request.Arguments.Add(new TagValue(CommonTags.MailWhiteLabelSettings, MailWhiteLabelSettings.Instance(_settingsManager))); - request.Arguments.Add(new TagValue(CommonTags.SendFrom, tenant.Name)); + request.Arguments.Add(new TagValue(CommonTags.SendFrom, tenant.Name == "" ? Resource.PortalName : tenant.Name)); request.Arguments.Add(new TagValue(CommonTags.ImagePath, _studioNotifyHelper.GetNotificationImageUrl("").TrimEnd('/'))); AddLetterLogo(request); diff --git a/web/ASC.Web.Core/PublicResources/Resource.Designer.cs b/web/ASC.Web.Core/PublicResources/Resource.Designer.cs index 0e08d1b640..859674322e 100644 --- a/web/ASC.Web.Core/PublicResources/Resource.Designer.cs +++ b/web/ASC.Web.Core/PublicResources/Resource.Designer.cs @@ -19,7 +19,7 @@ namespace ASC.Web.Core.PublicResources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resource { @@ -1995,6 +1995,15 @@ namespace ASC.Web.Core.PublicResources { } } + /// + /// Looks up a localized string similar to Cloud space for your office docs. + /// + public static string PortalName { + get { + return ResourceManager.GetString("PortalName", resourceCulture); + } + } + /// /// Looks up a localized string similar to Portal Access. /// diff --git a/web/ASC.Web.Core/PublicResources/Resource.resx b/web/ASC.Web.Core/PublicResources/Resource.resx index a0046aef39..9452deceed 100644 --- a/web/ASC.Web.Core/PublicResources/Resource.resx +++ b/web/ASC.Web.Core/PublicResources/Resource.resx @@ -828,4 +828,7 @@ Virtual room {0} invitations sent successfully. + + Cloud space for your office docs + \ No newline at end of file diff --git a/web/ASC.Web.Core/WhiteLabel/TenantInfoSettings.cs b/web/ASC.Web.Core/WhiteLabel/TenantInfoSettings.cs index 7ca121f24b..cc7acf6854 100644 --- a/web/ASC.Web.Core/WhiteLabel/TenantInfoSettings.cs +++ b/web/ASC.Web.Core/WhiteLabel/TenantInfoSettings.cs @@ -81,7 +81,7 @@ public class TenantInfoSettingsHelper public void RestoreDefaultTenantName() { var currentTenant = _tenantManager.GetCurrentTenant(); - currentTenant.Name = _configuration["web:portal-name"] ?? "Cloud Office Applications"; + currentTenant.Name = _configuration["web:portal-name"] ?? ""; _tenantManager.SaveTenant(currentTenant); }