Merge branch 'develop' into feature/fix-hide/show-header

This commit is contained in:
TatianaLopaeva 2020-11-05 10:35:16 +03:00
commit 8f47fe938c
57 changed files with 474 additions and 301 deletions

View File

@ -4,7 +4,6 @@ using ASC.Api.Core.Auth;
using ASC.Api.Core.Core;
using ASC.Api.Core.Middleware;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using Microsoft.AspNetCore.Authentication;
@ -100,8 +99,6 @@ namespace ASC.Api.Core
{
DIHelper.AddNLogManager(LogParams);
}
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)

View File

@ -28,9 +28,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ARSoft.Tools.NetStandard.DXSdata" Version="1.0.0" />
<PackageReference Include="Autofac" Version="5.2.0" />
<PackageReference Include="Autofac.Configuration" Version="5.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Autofac" Version="6.0.0" />
<PackageReference Include="Autofac.Configuration" Version="6.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Confluent.Kafka" Version="1.4.3" />
<PackageReference Include="Google.Protobuf" Version="3.13.0" />
<PackageReference Include="Grpc" Version="2.32.0" />

View File

@ -6,11 +6,8 @@ using System.Runtime.Loader;
using Autofac;
using Autofac.Configuration;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace ASC.Common.DependencyInjection
{
@ -26,7 +23,7 @@ namespace ASC.Common.DependencyInjection
public static class AutofacExtension
{
public static IContainer AddAutofac(this IServiceCollection services, IConfiguration configuration, string currentDir, bool loadproducts = true, bool loadconsumers = true, params string[] intern)
public static void Register(this ContainerBuilder builder, IConfiguration configuration, string currentDir, bool loadproducts = true, bool loadconsumers = true, params string[] intern)
{
var folder = configuration["core:products:folder"];
var subfolder = configuration["core:products:subfolder"];
@ -48,7 +45,6 @@ namespace ASC.Common.DependencyInjection
productsDir = folder;
}
var builder = new ContainerBuilder();
var modules = new List<(bool, string)>
{
(true, "autofac.json")
@ -88,13 +84,7 @@ namespace ASC.Common.DependencyInjection
}
}
builder.Populate(services);
var container = builder.Build();
services.TryAddSingleton(container);
return container;
return;
void FindAndLoad(IConfigurationSection sectionSettings)
{

View File

@ -53,5 +53,10 @@ namespace ASC.Core.Tenants
AuditTrailLifeTime = MaxLifeTime
};
}
}
public class TenantAuditSettingsWrapper
{
public TenantAuditSettings settings{ get; set; }
}
}

View File

@ -29,6 +29,7 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.Security.Authentication;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
@ -36,10 +37,12 @@ using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Common.Security;
using ASC.Security.Cryptography;
using ASC.Web.Core.Helpers;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
@ -61,7 +64,8 @@ namespace ASC.ApiSystem.Classes
IConfiguration configuration,
IOptionsMonitor<ILog> option,
ApiSystemHelper apiSystemHelper,
MachinePseudoKeys machinePseudoKeys) :
MachinePseudoKeys machinePseudoKeys,
IHttpContextAccessor httpContextAccessor) :
base(options, logger, encoder, clock)
{
Configuration = configuration;
@ -70,6 +74,7 @@ namespace ASC.ApiSystem.Classes
ApiSystemHelper = apiSystemHelper;
MachinePseudoKeys = machinePseudoKeys;
HttpContextAccessor = httpContextAccessor;
}
private ILog Log { get; }
@ -78,6 +83,7 @@ namespace ASC.ApiSystem.Classes
private ApiSystemHelper ApiSystemHelper { get; }
private MachinePseudoKeys MachinePseudoKeys { get; }
private IHttpContextAccessor HttpContextAccessor { get; }
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
@ -103,7 +109,7 @@ namespace ASC.ApiSystem.Classes
var substring = "ASC";
if (!header.StartsWith(substring, StringComparison.InvariantCultureIgnoreCase))
if (header.StartsWith(substring, StringComparison.InvariantCultureIgnoreCase))
{
var splitted = header.Substring(substring.Length).Trim().Split(':', StringSplitOptions.RemoveEmptyEntries);
@ -159,9 +165,10 @@ namespace ASC.ApiSystem.Classes
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(HttpStatusCode.InternalServerError.ToString())));
}
var identity = new ClaimsIdentity( Scheme.Name);
Log.InfoFormat("Auth success {0}", Scheme.Name);
if (HttpContextAccessor?.HttpContext != null) HttpContextAccessor.HttpContext.User = new CustomClaimsPrincipal(new ClaimsIdentity(Scheme.Name), identity);
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, new AuthenticationProperties(), Scheme.Name)));
}
}

View File

@ -47,7 +47,7 @@ namespace ASC.ApiSystem.Models
[StringLength(255)]
public string FirstName { get; set; }
[Email]
//todo [Email]
[StringLength(255)]
public string Email { get; set; }

View File

@ -25,7 +25,9 @@
using System.Collections.Generic;
using System.IO;
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@ -43,6 +45,7 @@ namespace ASC.ApiSystem
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -28,7 +28,9 @@ using ASC.ApiSystem.Classes;
using ASC.ApiSystem.Controllers;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Logging;
using Autofac;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
@ -81,8 +83,6 @@ namespace ASC.ApiSystem
.AddRegistrationController()
.AddSettingsController()
.AddTariffController();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath, false);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -114,6 +114,10 @@ namespace ASC.ApiSystem
{
endpoints.MapControllers();
});
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath, false);
}
}
}

View File

@ -1,17 +1,21 @@

using System;
using System.Collections.Generic;
using System.Linq;
using ASC.Api.Core.Middleware;
using ASC.Common;
using ASC.Core;
using ASC.Data.Backup.Contracts;
using ASC.Data.Backup.ModelApi;
using ASC.Data.Backup.Models;
using ASC.Web.Api.Routing;
using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Mvc;
using static ASC.Data.Backup.BackupAjaxHandler;
namespace ASC.Data.Backup.Controllers
{
[DefaultRoute]
@ -57,14 +61,23 @@ namespace ASC.Data.Backup.Controllers
/// <param name="backupMail">Include mail in the backup</param>
/// <category>Backup</category>
[Create("createbackupschedule")]
public void CreateBackupSchedule(BackupStorageType storageType, [FromQuery] Dictionary<string, string> storageParams, int backupsStored, [FromBody] BackupAjaxHandler.CronParams cronParams, bool backupMail)
public bool CreateBackupSchedule(BackupSchedule backupSchedule)
{
if (CoreBaseSettings.Standalone)
{
TenantExtra.DemandControlPanelPermission();
}
BackupHandler.CreateSchedule(storageType, storageParams, backupsStored, cronParams, backupMail);
var storageType = backupSchedule.StorageType == null ? BackupStorageType.Documents : (BackupStorageType)Int32.Parse(backupSchedule.StorageType);
var storageParams = backupSchedule.StorageParams == null ? new Dictionary<string, string>() : backupSchedule.StorageParams.ToDictionary(r => r.Key.ToString(), r => r.Value.ToString());
var backupStored = backupSchedule.BackupsStored == null ? 0 : Int32.Parse(backupSchedule.BackupsStored);
var cron = new CronParams()
{
Period = backupSchedule.CronParams.Period == null ? BackupPeriod.EveryDay : (BackupPeriod)Int32.Parse(backupSchedule.CronParams.Period),
Hour = backupSchedule.CronParams.Hour == null ? 0 : Int32.Parse(backupSchedule.CronParams.Hour),
Day = backupSchedule.CronParams.Day == null ? 0 : Int32.Parse(backupSchedule.CronParams.Day),
};
BackupHandler.CreateSchedule(storageType, storageParams, backupStored, cron, backupSchedule.BackupMail);
return true;
}
/// <summary>
@ -72,7 +85,7 @@ namespace ASC.Data.Backup.Controllers
/// </summary>
/// <category>Backup</category>
[Delete("deletebackupschedule")]
public void DeleteBackupSchedule()
public bool DeleteBackupSchedule()
{
if (CoreBaseSettings.Standalone)
{
@ -80,6 +93,8 @@ namespace ASC.Data.Backup.Controllers
}
BackupHandler.DeleteSchedule();
return true;
}
/// <summary>
@ -97,8 +112,9 @@ namespace ASC.Data.Backup.Controllers
{
TenantExtra.DemandControlPanelPermission();
}
BackupHandler.StartBackup(backup.StorageType, backup.StorageParams ?? new Dictionary<string, string>(), backup.BackupMail);
var storageType = backup.StorageType == null ? BackupStorageType.Documents : (BackupStorageType)Int32.Parse(backup.StorageType);
var storageParams = backup.StorageParams == null ? new Dictionary<string, string>() : backup.StorageParams.ToDictionary(r => r.Key.ToString(), r => r.Value.ToString());
BackupHandler.StartBackup(storageType, storageParams, backup.BackupMail);
return BackupHandler.GetBackupProgress();
}
@ -139,7 +155,7 @@ namespace ASC.Data.Backup.Controllers
/// </summary>
/// <category>Backup</category>
[Delete("deletebackup/{id}")]
public void DeleteBackup(Guid id)
public bool DeleteBackup(Guid id)
{
if (CoreBaseSettings.Standalone)
{
@ -147,6 +163,7 @@ namespace ASC.Data.Backup.Controllers
}
BackupHandler.DeleteBackup(id);
return true;
}
/// <summary>
@ -155,7 +172,7 @@ namespace ASC.Data.Backup.Controllers
/// <category>Backup</category>
/// <returns>Backup History</returns>
[Delete("deletebackuphistory")]
public void DeleteBackupHistory()
public bool DeleteBackupHistory()
{
if (CoreBaseSettings.Standalone)
{
@ -163,6 +180,7 @@ namespace ASC.Data.Backup.Controllers
}
BackupHandler.DeleteAllBackups();
return true;
}
/// <summary>
@ -181,8 +199,8 @@ namespace ASC.Data.Backup.Controllers
{
TenantExtra.DemandControlPanelPermission();
}
BackupHandler.StartRestore(backupRestore.BackupId, backupRestore.StorageType, backupRestore.StorageParams, backupRestore.Notify);
var storageParams = backupRestore.StorageParams == null ? new Dictionary<string, string>() : backupRestore.StorageParams.ToDictionary(r => r.Key.ToString(), r => r.Value.ToString());
BackupHandler.StartRestore(backupRestore.BackupId, (BackupStorageType)Int32.Parse(backupRestore.StorageType.ToString()), storageParams, backupRestore.Notify);
return BackupHandler.GetBackupProgress();
}

View File

@ -1,14 +1,16 @@

using System.Collections.Generic;
using ASC.Api.Collections;
using ASC.Data.Backup.Contracts;
namespace ASC.Data.Backup.Models
{
public class Backup
{
public BackupStorageType StorageType { get; set; }
public string StorageType { get; set; }
public bool BackupMail { get; set; }
public Dictionary<string, string> StorageParams { get; set; }
public IEnumerable<ItemKeyValuePair<object, object>> StorageParams { get; set; }
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using ASC.Api.Collections;
using ASC.Data.Backup.Contracts;
namespace ASC.Data.Backup.Models
@ -7,8 +8,8 @@ namespace ASC.Data.Backup.Models
public class BackupRestore
{
public string BackupId { get; set; }
public BackupStorageType StorageType { get; set; }
public Dictionary<string, string> StorageParams { get; set; }
public object StorageType { get; set; }
public IEnumerable<ItemKeyValuePair<object, object>> StorageParams { get; set; }
public bool Notify { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ASC.Api.Collections;
using ASC.Data.Backup.Contracts;
using static ASC.Data.Backup.BackupAjaxHandler;
namespace ASC.Data.Backup.ModelApi
{
public class BackupSchedule
{
public string StorageType { get; set; }
public IEnumerable<ItemKeyValuePair<object, object>> StorageParams { get; set; }
public string BackupsStored { get; set; }
public Cron CronParams { get; set; }
public bool BackupMail { get; set; }
}
public class Cron
{
public string Period { get; set; }
public string Hour { get; set; }
public string Day { get; set; }
}
}

View File

@ -2,6 +2,8 @@
using System.IO;
using System.Threading.Tasks;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -12,7 +14,8 @@ namespace ASC.Data.Backup
{
public static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
await Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -512,6 +512,7 @@ namespace ASC.Data.Backup.Service
try
{
tenant = tenantManager.GetTenant(TenantId);
tenantManager.SetCurrentTenant(tenant);
notifyHelper.SendAboutRestoreStarted(tenant, Notify);
var storage = backupStorageFactory.GetBackupStorage(StorageType, TenantId, StorageParams);
storage.Download(StoragePath, tempFile);
@ -561,7 +562,7 @@ namespace ASC.Data.Backup.Service
restoredTenant.MappedDomain = tenant.MappedDomain;
}
tenantManager.SaveTenant(restoredTenant);
tenantManager.SetCurrentTenant(restoredTenant);
// sleep until tenants cache expires
Thread.Sleep(TimeSpan.FromMinutes(2));
@ -592,6 +593,7 @@ namespace ASC.Data.Backup.Service
{
try
{
IsCompleted = true;
backupWorker.PublishProgress(this);
}
catch (Exception error)
@ -603,7 +605,6 @@ namespace ASC.Data.Backup.Service
{
File.Delete(tempFile);
}
IsCompleted = true;
}
}
@ -702,6 +703,8 @@ namespace ASC.Data.Backup.Service
{
try
{
IsCompleted = true;
backupWorker.PublishProgress(this);
}
catch (Exception error)
@ -713,7 +716,6 @@ namespace ASC.Data.Backup.Service
{
File.Delete(tempFile);
}
IsCompleted = true;
}
}

View File

@ -1,10 +1,13 @@
using System;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Data.Backup.Controllers;
using ASC.Data.Backup.Service;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -29,6 +32,11 @@ namespace ASC.Data.Backup
.AddProgressQueue<BaseBackupProgressItem>(1, (int)TimeSpan.FromMinutes(5).TotalMilliseconds, true, false, 0);
services.AddHostedService<BackupServiceLauncher>();
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
}
}

View File

@ -24,8 +24,10 @@
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -36,7 +38,8 @@ namespace ASC.Data.Storage.Encryption
{
public static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
await Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -24,10 +24,10 @@
*/
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common;
using ASC.Common.DependencyInjection;
using Autofac.Extensions.DependencyInjection;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -51,8 +51,11 @@ namespace ASC.Data.Storage.Encryption
DIHelper.AddEncryptionServiceLauncher();
services.AddHostedService<EncryptionServiceLauncher>();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
}
}

View File

@ -5,8 +5,10 @@ using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Core.Common;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -17,7 +19,8 @@ namespace ASC.Data.Storage.Migration
{
public static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
await Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -52,8 +55,10 @@ namespace ASC.Data.Storage.Migration
diHelper.AddMigrationServiceLauncher();
services.AddHostedService<MigrationServiceLauncher>();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath);
})
.UseConsoleLifetime()
.Build()

View File

@ -461,18 +461,9 @@ namespace ASC.ElasticSearch
FactoryIndexerHelper factoryIndexerHelper,
Client client,
IOptionsMonitor<ILog> options,
CoreBaseSettings coreBaseSettings) : this(null, factoryIndexerHelper, client, options, coreBaseSettings)
{
Builder = container;
}
public FactoryIndexer(
IContainer container,
FactoryIndexerHelper factoryIndexerHelper,
Client client,
IOptionsMonitor<ILog> options,
CoreBaseSettings coreBaseSettings)
{
Builder = container;
FactoryIndexerHelper = factoryIndexerHelper;
Client = client;
CoreBaseSettings = coreBaseSettings;

View File

@ -48,7 +48,7 @@ namespace ASC.ElasticSearch
private ICacheNotify<AscCacheItem> Notify { get; }
private ICacheNotify<IndexAction> IndexNotify { get; }
private IServiceProvider ServiceProvider { get; }
public IContainer Container { get; }
public ILifetimeScope Container { get; }
private bool IsStarted { get; set; }
private CancellationTokenSource CancellationTokenSource { get; set; }
private Timer Timer { get; set; }
@ -59,7 +59,7 @@ namespace ASC.ElasticSearch
ICacheNotify<AscCacheItem> notify,
ICacheNotify<IndexAction> indexNotify,
IServiceProvider serviceProvider,
IContainer container,
ILifetimeScope container,
Settings settings)
{
Log = options.Get("ASC.Indexer");

View File

@ -42,11 +42,11 @@ namespace ASC.ElasticSearch.Service
{
public class Service
{
public IContainer Container { get; }
private ILifetimeScope Container { get; }
private IServiceProvider ServiceProvider { get; }
private ICacheNotify<ReIndexAction> CacheNotify { get; }
public Service(IContainer container, IServiceProvider serviceProvider, ICacheNotify<ReIndexAction> cacheNotify)
public Service(ILifetimeScope container, IServiceProvider serviceProvider, ICacheNotify<ReIndexAction> cacheNotify)
{
Container = container;
ServiceProvider = serviceProvider;

View File

@ -63,12 +63,12 @@ namespace ASC.Feed.Aggregator
private IConfiguration Configuration { get; }
private IServiceProvider ServiceProvider { get; }
public IContainer Container { get; }
public ILifetimeScope Container { get; }
public FeedAggregatorService(
IConfiguration configuration,
IServiceProvider serviceProvider,
IContainer container,
ILifetimeScope container,
IOptionsMonitor<ILog> optionsMonitor,
SignalrServiceClient signalrServiceClient,
IConfigureNamedOptions<SignalrServiceClient> configureOptions)

View File

@ -31,7 +31,6 @@ using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Core.Common;
using ASC.Notify.Config;
using ASC.Web.Core;
using ASC.Web.Studio.Core.Notify;

View File

@ -5,11 +5,13 @@ using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Core.Common;
using ASC.Core.Notify;
using ASC.Core.Notify.Senders;
using ASC.Notify.Config;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -22,6 +24,7 @@ namespace ASC.Notify
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -65,8 +68,10 @@ namespace ASC.Notify
.AddSmtpSenderService()
.AddAWSSenderService()
.AddEmailSenderSinkService();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath);
})
.UseConsoleLifetime()
.Build();

View File

@ -28,10 +28,13 @@ using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Logging;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -43,7 +46,8 @@ namespace ASC.Socket.IO.Svc
{
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -77,8 +81,10 @@ namespace ASC.Socket.IO.Svc
diHelper.AddNLogManager("ASC.Socket.IO.Svc");
services.AddHostedService<SocketServiceLauncher>();
diHelper.AddSocketServiceLauncher();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, false, false);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath, false, false);
})
.UseConsoleLifetime()
.Build();

View File

@ -40,8 +40,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using WebSocketSharp;
namespace ASC.Socket.IO.Svc
{
public class SocketServiceLauncher : IHostedService

View File

@ -8,6 +8,9 @@ using ASC.Common.Logging;
using ASC.Core.Notify;
using ASC.Notify;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -19,6 +22,7 @@ namespace ASC.Studio.Notify
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -52,7 +56,10 @@ namespace ASC.Studio.Notify
services.AddHostedService<ServiceLauncher>();
diHelper.AddServiceLauncher();
diHelper.AddEmailSenderSinkService();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath);
})
.UseConsoleLifetime()
.Build();

View File

@ -24,8 +24,10 @@
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -36,7 +38,8 @@ namespace ASC.TelegramService
{
public static async Task Main(string[] args)
{
await Host.CreateDefaultBuilder(args)
await Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -25,9 +25,9 @@
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.DependencyInjection;
using Autofac.Extensions.DependencyInjection;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -51,8 +51,11 @@ namespace ASC.TelegramService
DIHelper.AddTelegramLauncher();
services.AddHostedService<TelegramLauncher>();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
}
}

View File

@ -27,11 +27,14 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -43,7 +46,8 @@ namespace ASC.Thumbnails.Svc
{
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -76,8 +80,10 @@ namespace ASC.Thumbnails.Svc
diHelper.AddNLogManager("ASC.Thumbnails.Svc");
services.AddHostedService<ThumbnailsServiceLauncher>();
diHelper.AddThumbnailsServiceLauncher();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, false, false);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath, false, false);
})
.UseConsoleLifetime()
.Build();

View File

@ -28,10 +28,13 @@ using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Logging;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -43,7 +46,8 @@ namespace ASC.UrlShortener.Svc
{
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -75,8 +79,10 @@ namespace ASC.UrlShortener.Svc
diHelper.AddNLogManager("ASC.UrlShortener.Svc");
services.AddHostedService<UrlShortenerServiceLauncher>();
diHelper.AddUrlShortenerServiceLauncher();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, false, false);
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath, false, false);
})
.UseConsoleLifetime()
.Build();

View File

@ -97,24 +97,35 @@ server {
}
location /api/2.0 {
proxy_pass http://localhost:5000;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /(people|group) {
proxy_pass http://localhost:5004;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /(files|encryption) {
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /(files|encryption) {
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /(authentication|modules|portal|security|settings|smtpsettings|capabilities) {
proxy_pass http://localhost:5000;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* portal/(.*)(backup|restore)(.*) {
rewrite (.*)/portal/(.*) $1/backup/$2 break;
proxy_redirect off;
proxy_pass http://localhost:5012;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location ~* /(people|group) {
proxy_pass http://localhost:5004;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /backup {
proxy_pass http://localhost:5012;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
proxy_pass http://localhost:5012;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
}
location /storage {
proxy_pass http://localhost:5003;

View File

@ -19,7 +19,7 @@
<meta name="mobile-web-app-capable" content="yes" />
<!-- Tell iOS it's a PWA -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="icon.png" />
<link rel="apple-touch-icon" href="appIcon.png" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i"

View File

@ -90,10 +90,6 @@ namespace ASC.Api.Documents
private UserManager UserManager { get; }
private CoreBaseSettings CoreBaseSettings { get; }
private ThirdpartyConfiguration ThirdpartyConfiguration { get; }
private BoxLoginProvider BoxLoginProvider { get; }
private DropboxLoginProvider DropboxLoginProvider { get; }
private GoogleLoginProvider GoogleLoginProvider { get; }
private OneDriveLoginProvider OneDriveLoginProvider { get; }
private MessageService MessageService { get; }
private CommonLinkUtility CommonLinkUtility { get; }
private DocumentServiceConnector DocumentServiceConnector { get; }
@ -150,10 +146,6 @@ namespace ASC.Api.Documents
CoreBaseSettings = coreBaseSettings;
ThirdpartyConfiguration = thirdpartyConfiguration;
ConsumerFactory = consumerFactory;
BoxLoginProvider = ConsumerFactory.Get<BoxLoginProvider>();
DropboxLoginProvider = ConsumerFactory.Get<DropboxLoginProvider>();
GoogleLoginProvider = ConsumerFactory.Get<GoogleLoginProvider>();
OneDriveLoginProvider = ConsumerFactory.Get<OneDriveLoginProvider>();
MessageService = messageService;
CommonLinkUtility = commonLinkUtility;
DocumentServiceConnector = documentServiceConnector;
@ -1357,19 +1349,25 @@ namespace ASC.Api.Documents
if (ThirdpartyConfiguration.SupportBoxInclusion)
{
result.Add(new List<string> { "Box", BoxLoginProvider.ClientID, BoxLoginProvider.RedirectUri });
var boxLoginProvider = ConsumerFactory.Get<BoxLoginProvider>();
result.Add(new List<string> { "Box", boxLoginProvider.ClientID, boxLoginProvider.RedirectUri });
}
if (ThirdpartyConfiguration.SupportDropboxInclusion)
{
result.Add(new List<string> { "DropboxV2", DropboxLoginProvider.ClientID, DropboxLoginProvider.RedirectUri });
var dropboxLoginProvider = ConsumerFactory.Get<DropboxLoginProvider>();
result.Add(new List<string> { "DropboxV2", dropboxLoginProvider.ClientID, dropboxLoginProvider.RedirectUri });
}
if (ThirdpartyConfiguration.SupportGoogleDriveInclusion)
{
result.Add(new List<string> { "GoogleDrive", GoogleLoginProvider.ClientID, GoogleLoginProvider.RedirectUri });
var googleLoginProvider = ConsumerFactory.Get<GoogleLoginProvider>();
result.Add(new List<string> { "GoogleDrive", googleLoginProvider.ClientID, googleLoginProvider.RedirectUri });
}
if (ThirdpartyConfiguration.SupportOneDriveInclusion)
{
result.Add(new List<string> { "OneDrive", OneDriveLoginProvider.ClientID, OneDriveLoginProvider.RedirectUri });
var oneDriveLoginProvider = ConsumerFactory.Get<OneDriveLoginProvider>();
result.Add(new List<string> { "OneDrive", oneDriveLoginProvider.ClientID, oneDriveLoginProvider.RedirectUri });
}
if (ThirdpartyConfiguration.SupportSharePointInclusion)
{

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -17,6 +19,7 @@ namespace ASC.Files
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -1,4 +1,3 @@
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;

View File

@ -11,6 +11,9 @@ using ASC.Feed.Aggregator;
using ASC.Web.Files.Core.Search;
using ASC.Web.Files.Utils;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -22,6 +25,7 @@ namespace ASC.Files.Service
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
@ -65,8 +69,10 @@ namespace ASC.Files.Service
services.AddHostedService<FeedAggregatorService>();
diHelper
.AddFeedAggregatorService();
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath, true, false, "search.json", "feed.json");
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, context.HostingEnvironment.ContentRootPath, true, false, "search.json", "feed.json");
})
.UseConsoleLifetime()
.Build();

View File

@ -19,7 +19,7 @@
<meta name="mobile-web-app-capable" content="yes" />
<!-- Tell iOS it's a PWA -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="icon.png" />
<link rel="apple-touch-icon" href="appIcon.png" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i"

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -17,6 +19,7 @@ namespace ASC.People
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -2,11 +2,14 @@
using System;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Data.Reassigns;
using ASC.Employee.Core.Controllers;
using ASC.Web.Core.Users;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -33,6 +36,11 @@ namespace ASC.People
DIHelper
.AddPeopleController()
.AddGroupController();
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
}
}

View File

@ -2,14 +2,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Common.Settings;
using ASC.FederatedLogin;
using ASC.FederatedLogin.LoginProviders;
using ASC.Web.Api.Models;
using ASC.Web.Api.Routing;

View File

@ -8,7 +8,6 @@ using ASC.Common;
using ASC.Common.Logging;
using ASC.Core;
using ASC.Core.Billing;
using ASC.Core.Common.Notify.Push;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using ASC.Core.Users;
@ -21,6 +20,8 @@ using ASC.Web.Core.Mobile;
using ASC.Web.Core.Utility;
using ASC.Web.Studio.Core;
using ASC.Web.Studio.Core.Notify;
using ASC.Web.Studio.UserControls.Management;
using ASC.Web.Studio.UserControls.Statistics;
using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Mvc;
@ -50,7 +51,8 @@ namespace ASC.Web.Api.Controllers
private SettingsManager SettingsManager { get; }
private IMobileAppInstallRegistrator MobileAppInstallRegistrator { get; }
private IConfiguration Configuration { get; set; }
private ILog Log { get; }
private TenantExtra TenantExtra { get; set; }
public ILog Log { get; }
public PortalController(
@ -66,6 +68,7 @@ namespace ASC.Web.Api.Controllers
SecurityContext securityContext,
SettingsManager settingsManager,
IMobileAppInstallRegistrator mobileAppInstallRegistrator,
TenantExtra tenantExtra,
IConfiguration configuration
)
{
@ -82,6 +85,7 @@ namespace ASC.Web.Api.Controllers
SettingsManager = settingsManager;
MobileAppInstallRegistrator = mobileAppInstallRegistrator;
Configuration = configuration;
TenantExtra = tenantExtra;
}
[Read("")]
@ -122,6 +126,20 @@ namespace ASC.Web.Api.Controllers
}
}
[Read("tenantextra")]
public object GetTenantExtra()
{
return new
{
opensource = TenantExtra.Opensource,
enterprise = TenantExtra.Enterprise,
tariff = TenantExtra.GetCurrentTariff(),
quota = TenantExtra.GetTenantQuota(),
notPaid = TenantExtra.IsNotPaid(),
licenseAccept = SettingsManager.LoadForCurrentUser<TariffSettings>().LicenseAcceptSetting
};
}
[Read("usedspace")]
public double GetUsedSpace()
@ -208,7 +226,7 @@ namespace ASC.Web.Api.Controllers
{
var currentUser = UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
MobileAppInstallRegistrator.RegisterInstall(currentUser.Email, model.Type);
}
}
}
public static class PortalControllerExtension
@ -230,7 +248,8 @@ namespace ASC.Web.Api.Controllers
.AddAuthContextService()
.AddWebItemSecurity()
.AddSecurityContextService()
.AddCachedMobileAppInstallRegistrator();
.AddCachedMobileAppInstallRegistrator()
.AddTenantExtraService();
}
}
}

View File

@ -134,20 +134,20 @@ namespace ASC.Web.Api.Controllers
}
[Create("audit/settings/lifetime")]
public TenantAuditSettings SetAuditSettings(TenantAuditSettings settings)
public TenantAuditSettings SetAuditSettings(TenantAuditSettingsWrapper wrapper)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (settings.LoginHistoryLifeTime <= 0 || settings.LoginHistoryLifeTime > TenantAuditSettings.MaxLifeTime)
if (wrapper.settings.LoginHistoryLifeTime <= 0 || wrapper.settings.LoginHistoryLifeTime > TenantAuditSettings.MaxLifeTime)
throw new ArgumentException("LoginHistoryLifeTime");
if (settings.AuditTrailLifeTime <= 0 || settings.AuditTrailLifeTime > TenantAuditSettings.MaxLifeTime)
if (wrapper.settings.AuditTrailLifeTime <= 0 || wrapper.settings.AuditTrailLifeTime > TenantAuditSettings.MaxLifeTime)
throw new ArgumentException("AuditTrailLifeTime");
SettingsManager.SaveForTenant(settings, TenantManager.GetCurrentTenant().TenantId);
SettingsManager.SaveForTenant(wrapper.settings, TenantManager.GetCurrentTenant().TenantId);
MessageService.Send(MessageAction.AuditSettingsUpdated);
return settings;
return wrapper.settings;
}
}

View File

@ -36,6 +36,8 @@ using System.ServiceModel.Security;
using System.Text.RegularExpressions;
using System.Web;
using ARSoft.Tools.Net.Dns;
using ASC.Api.Collections;
using ASC.Api.Core;
using ASC.Api.Utils;
@ -51,6 +53,7 @@ using ASC.Core.Common.Notify;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using ASC.Core.Users;
using ASC.Data.Backup;
using ASC.Data.Backup.Contracts;
using ASC.Data.Backup.Service;
using ASC.Data.Storage;
@ -166,6 +169,7 @@ namespace ASC.Api.Settings
private PasswordHasher PasswordHasher { get; }
private ILog Log { get; set; }
private TelegramHelper TelegramHelper { get; }
private BackupAjaxHandler BackupAjaxHandler { get; }
public SettingsController(
IOptionsMonitor<ILog> option,
@ -227,7 +231,8 @@ namespace ASC.Api.Settings
BackupServiceNotifier backupServiceNotifier,
ICacheNotify<DeleteSchedule> cacheDeleteSchedule,
EncryptionServiceNotifier encryptionServiceNotifier,
PasswordHasher passwordHasher)
PasswordHasher passwordHasher,
BackupAjaxHandler backupAjaxHandler)
{
Log = option.Get("ASC.Api");
WebHostEnvironment = webHostEnvironment;
@ -289,6 +294,7 @@ namespace ASC.Api.Settings
StorageFactory = storageFactory;
UrlShortener = urlShortener;
TelegramHelper = telegramHelper;
BackupAjaxHandler = backupAjaxHandler;
}
[Read("", Check = false)]
@ -345,7 +351,7 @@ namespace ASC.Api.Settings
MessageService.Send(MessageAction.AdministratorMessageSettingsUpdated);
return Resource.SuccessfullySaveSettingsMessage;
return Resource.SuccessfullySaveSettingsMessage;
}
[AllowAnonymous]
@ -440,23 +446,23 @@ namespace ASC.Api.Settings
switch (Tenant.TrustedDomainsType)
{
case TenantTrustedDomainsType.Custom:
{
var address = new MailAddress(email);
if (Tenant.TrustedDomains.Any(d => address.Address.EndsWith("@" + d, StringComparison.InvariantCultureIgnoreCase)))
{
StudioNotifyService.SendJoinMsg(email, emplType);
MessageService.Send(MessageInitiator.System, MessageAction.SentInviteInstructions, email);
return Resource.FinishInviteJoinEmailMessage;
}
throw new Exception(Resource.ErrorEmailDomainNotAllowed);
}
case TenantTrustedDomainsType.All:
{
var address = new MailAddress(email);
if (Tenant.TrustedDomains.Any(d => address.Address.EndsWith("@" + d, StringComparison.InvariantCultureIgnoreCase)))
{
StudioNotifyService.SendJoinMsg(email, emplType);
MessageService.Send(MessageInitiator.System, MessageAction.SentInviteInstructions, email);
return Resource.FinishInviteJoinEmailMessage ;
return Resource.FinishInviteJoinEmailMessage;
}
throw new Exception(Resource.ErrorEmailDomainNotAllowed);
}
case TenantTrustedDomainsType.All:
{
StudioNotifyService.SendJoinMsg(email, emplType);
MessageService.Send(MessageInitiator.System, MessageAction.SentInviteInstructions, email);
return Resource.FinishInviteJoinEmailMessage;
}
default:
throw new Exception(Resource.ErrorNotCorrectEmail);
}
@ -885,7 +891,7 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Create("whitelabel/save")]
public void SaveWhiteLabelSettings(WhiteLabelModel model)
public bool SaveWhiteLabelSettings([FromBody] WhiteLabelModel model, [FromQuery] WhiteLabelQuery query)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
@ -894,7 +900,7 @@ namespace ASC.Api.Settings
throw new BillingException(Resource.ErrorNotAllowedOption, "WhiteLabel");
}
if (model.IsDefault)
if (query.IsDefault)
{
DemandRebrandingPermission();
SaveWhiteLabelSettingsForDefaultTenant(model);
@ -903,6 +909,7 @@ namespace ASC.Api.Settings
{
SaveWhiteLabelSettingsForCurrentTenant(model);
}
return true;
}
private void SaveWhiteLabelSettingsForCurrentTenant(WhiteLabelModel model)
@ -925,7 +932,7 @@ namespace ASC.Api.Settings
if (model.Logo != null)
{
var logoDict = new Dictionary<int, string>();
model.Logo.ToList().ForEach(n => logoDict.Add(n.Key, n.Value));
model.Logo.ToList().ForEach(n => logoDict.Add(Int32.Parse(n.Key), n.Value));
TenantWhiteLabelSettingsHelper.SetLogo(settings, logoDict, storage);
}
@ -938,7 +945,7 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Create("whitelabel/savefromfiles")]
public void SaveWhiteLabelSettingsFromFiles(WhiteLabelModel model)
public bool SaveWhiteLabelSettingsFromFiles([FromQuery] WhiteLabelQuery query)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
@ -947,40 +954,41 @@ namespace ASC.Api.Settings
throw new BillingException(Resource.ErrorNotAllowedOption, "WhiteLabel");
}
if (model.Attachments == null || !model.Attachments.Any())
if (HttpContext.Request.Form?.Files == null || !HttpContext.Request.Form.Files.Any())
{
throw new InvalidOperationException("No input files");
}
if (model.IsDefault)
if (query.IsDefault)
{
DemandRebrandingPermission();
SaveWhiteLabelSettingsFromFilesForDefaultTenant(model);
SaveWhiteLabelSettingsFromFilesForDefaultTenant();
}
else
{
SaveWhiteLabelSettingsFromFilesForCurrentTenant(model);
SaveWhiteLabelSettingsFromFilesForCurrentTenant();
}
return true;
}
private void SaveWhiteLabelSettingsFromFilesForCurrentTenant(WhiteLabelModel model)
private void SaveWhiteLabelSettingsFromFilesForCurrentTenant()
{
var settings = SettingsManager.Load<TenantWhiteLabelSettings>();
SaveWhiteLabelSettingsFromFilesForTenant(settings, null, Tenant.TenantId, model);
SaveWhiteLabelSettingsFromFilesForTenant(settings, null, Tenant.TenantId);
}
private void SaveWhiteLabelSettingsFromFilesForDefaultTenant(WhiteLabelModel model)
private void SaveWhiteLabelSettingsFromFilesForDefaultTenant()
{
var settings = SettingsManager.LoadForDefaultTenant<TenantWhiteLabelSettings>();
var storage = StorageFactory.GetStorage(string.Empty, "static_partnerdata");
SaveWhiteLabelSettingsFromFilesForTenant(settings, storage, Tenant.DEFAULT_TENANT, model);
SaveWhiteLabelSettingsFromFilesForTenant(settings, storage, Tenant.DEFAULT_TENANT);
}
private void SaveWhiteLabelSettingsFromFilesForTenant(TenantWhiteLabelSettings settings, IDataStore storage, int tenantId, WhiteLabelModel model)
private void SaveWhiteLabelSettingsFromFilesForTenant(TenantWhiteLabelSettings settings, IDataStore storage, int tenantId)
{
foreach (var f in model.Attachments)
foreach (var f in HttpContext.Request.Form.Files)
{
var parts = f.FileName.Split('.');
var logoType = (WhiteLabelLogoTypeEnum)(Convert.ToInt32(parts[0]));
@ -1017,7 +1025,7 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Read("whitelabel/logos")]
public Dictionary<int, string> GetWhiteLabelLogos(WhiteLabelModel model)
public Dictionary<string, string> GetWhiteLabelLogos([FromQuery] WhiteLabelQuery query)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
@ -1026,30 +1034,30 @@ namespace ASC.Api.Settings
throw new BillingException(Resource.ErrorNotAllowedOption, "WhiteLabel");
}
Dictionary<int, string> result;
Dictionary<string, string> result;
if (model.IsDefault)
if (query.IsDefault)
{
DemandRebrandingPermission();
result = new Dictionary<int, string>
result = new Dictionary<string, string>
{
{ (int)WhiteLabelLogoTypeEnum.LightSmall, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LightSmall, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.Dark, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Dark, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.Favicon, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Favicon, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.DocsEditor, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditor, !model.IsRetina)) }
{ ((int)WhiteLabelLogoTypeEnum.LightSmall).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LightSmall, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.Dark).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Dark, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.Favicon).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Favicon, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.DocsEditor).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditor, !query.IsRetina)) }
};
}
else
{
var _tenantWhiteLabelSettings = SettingsManager.Load<TenantWhiteLabelSettings>();
result = new Dictionary<int, string>
result = new Dictionary<string, string>
{
{ (int)WhiteLabelLogoTypeEnum.LightSmall, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LightSmall, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.Dark, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Dark, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.Favicon, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Favicon, !model.IsRetina)) },
{ (int)WhiteLabelLogoTypeEnum.DocsEditor, CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditor, !model.IsRetina)) }
{ ((int)WhiteLabelLogoTypeEnum.LightSmall).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LightSmall, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.Dark).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Dark, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.Favicon).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Favicon, !query.IsRetina)) },
{ ((int)WhiteLabelLogoTypeEnum.DocsEditor).ToString(), CommonLinkUtility.GetFullAbsolutePath(TenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditor, !query.IsRetina)) }
};
}
@ -1058,7 +1066,7 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Read("whitelabel/logotext")]
public object GetWhiteLabelLogoText(WhiteLabelModel model)
public object GetWhiteLabelLogoText([FromQuery] WhiteLabelQuery query)
{
if (!TenantLogoManager.WhiteLabelEnabled)
{
@ -1066,12 +1074,12 @@ namespace ASC.Api.Settings
}
if (model.IsDefault)
if (query.IsDefault)
{
DemandRebrandingPermission();
}
var settings = model.IsDefault ? SettingsManager.LoadForDefaultTenant<TenantWhiteLabelSettings>() : SettingsManager.Load<TenantWhiteLabelSettings>();
var settings = query.IsDefault ? SettingsManager.LoadForDefaultTenant<TenantWhiteLabelSettings>() : SettingsManager.Load<TenantWhiteLabelSettings>();
return settings.LogoText ?? TenantWhiteLabelSettings.DefaultLogoText;
}
@ -1079,7 +1087,7 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Update("whitelabel/restore")]
public void RestoreWhiteLabelOptions(WhiteLabelModel model)
public bool RestoreWhiteLabelOptions(WhiteLabelQuery query)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
@ -1087,7 +1095,7 @@ namespace ASC.Api.Settings
{
throw new BillingException(Resource.ErrorNotAllowedOption, "WhiteLabel");
}
if (model.IsDefault)
if (query.IsDefault)
{
DemandRebrandingPermission();
RestoreWhiteLabelOptionsForDefaultTenant();
@ -1096,6 +1104,7 @@ namespace ASC.Api.Settings
{
RestoreWhiteLabelOptionsForCurrentTenant();
}
return true;
}
private void RestoreWhiteLabelOptionsForCurrentTenant()
@ -1776,23 +1785,10 @@ namespace ASC.Api.Settings
return ServiceClient.GetProgress(Tenant.TenantId);
}
[Read("encryption")]
public void StartEncryption(EncryptionSettingsModel settings)
{
var encryptionSettingsProto = new EncryptionSettingsProto
{
NotifyUsers = settings.NotifyUsers,
Password = settings.Password,
Status = settings.Status,
ServerRootPath = settings.ServerRootPath
};
EncryptionServiceClient.Start(encryptionSettingsProto);
}
public readonly object Locker = new object();
[Create("encryption/start")]
public void StartStorageEncryption(StorageEncryptionModel storageEncryption)
public bool StartStorageEncryption(StorageEncryptionModel storageEncryption)
{
lock (Locker)
{
@ -1803,6 +1799,7 @@ namespace ASC.Api.Settings
StartEncryption(storageEncryption.NotifyUsers);
}
}
return true;
}
private void StartEncryption(bool notifyUsers)
@ -2079,29 +2076,29 @@ namespace ASC.Api.Settings
StorageSettingsHelper.Clear(SettingsManager.Load<CdnStorageSettings>());
}
//[Read("storage/backup")]
//public List<StorageWrapper> GetAllBackupStorages()
//{
// PermissionContext.DemandPermissions(Tenant, SecutiryConstants.EditPortalSettings);
//if (CoreContext.Configuration.Standalone)
//{
// TenantExtra.DemandControlPanelPermission();
//}
// var schedule = new BackupAjaxHandler().GetSchedule();
// var current = new StorageSettings();
[Read("storage/backup")]
public List<StorageWrapper> GetAllBackupStorages()
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (CoreBaseSettings.Standalone)
{
TenantExtra.DemandControlPanelPermission();
}
var schedule = BackupAjaxHandler.GetSchedule();
var current = new StorageSettings();
// if (schedule != null && schedule.StorageType == Contracts.BackupStorageType.ThirdPartyConsumer)
// {
// current = new StorageSettings
// {
// Module = schedule.StorageParams["module"],
// Props = schedule.StorageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value)
// };
// }
if (schedule != null && schedule.StorageType == BackupStorageType.ThirdPartyConsumer)
{
current = new StorageSettings
{
Module = schedule.StorageParams["module"],
Props = schedule.StorageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value)
};
}
// var consumers = ConsumerFactory.GetAll<DataStoreConsumer>().ToList();
// return consumers.Select(consumer => new StorageWrapper(consumer, current)).ToList();
//}
var consumers = ConsumerFactory.GetAll<DataStoreConsumer>().ToList();
return consumers.Select(consumer => new StorageWrapper(consumer, current)).ToList();
}
private void StartMigrate(StorageSettings settings)
{
@ -2135,15 +2132,16 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Create("rebranding/company")]
public void SaveCompanyWhiteLabelSettings(CompanyWhiteLabelSettings settings)
public bool SaveCompanyWhiteLabelSettings(CompanyWhiteLabelSettingsWrapper companyWhiteLabelSettingsWrapper)
{
if (settings == null) throw new ArgumentNullException("settings");
if (companyWhiteLabelSettingsWrapper.Settings == null) throw new ArgumentNullException("settings");
DemandRebrandingPermission();
settings.IsLicensorSetting = false; //TODO: CoreContext.TenantManager.GetTenantQuota(TenantProvider.CurrentTenantID).Branding && settings.IsLicensor
companyWhiteLabelSettingsWrapper.Settings.IsLicensorSetting = false; //TODO: CoreContext.TenantManager.GetTenantQuota(TenantProvider.CurrentTenantID).Branding && settings.IsLicensor
SettingsManager.SaveForDefaultTenant(settings);
SettingsManager.SaveForDefaultTenant(companyWhiteLabelSettingsWrapper.Settings);
return true;
}
///<visible>false</visible>
@ -2168,13 +2166,14 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Create("rebranding/additional")]
public void SaveAdditionalWhiteLabelSettings(AdditionalWhiteLabelSettings settings)
public bool SaveAdditionalWhiteLabelSettings(AdditionalWhiteLabelSettingsWrapper wrapper)
{
if (settings == null) throw new ArgumentNullException("settings");
if (wrapper.Settings == null) throw new ArgumentNullException("settings");
DemandRebrandingPermission();
SettingsManager.SaveForDefaultTenant(settings);
SettingsManager.SaveForDefaultTenant(wrapper.Settings);
return true;
}
///<visible>false</visible>
@ -2199,18 +2198,19 @@ namespace ASC.Api.Settings
///<visible>false</visible>
[Create("rebranding/mail")]
public void SaveMailWhiteLabelSettings(MailWhiteLabelSettings settings)
public bool SaveMailWhiteLabelSettings(MailWhiteLabelSettings settings)
{
if (settings == null) throw new ArgumentNullException("settings");
DemandRebrandingPermission();
SettingsManager.SaveForDefaultTenant(settings);
return true;
}
///<visible>false</visible>
[Update("rebranding/mail")]
public void UpdateMailWhiteLabelSettings(bool footerEnabled)
public bool UpdateMailWhiteLabelSettings(bool footerEnabled)
{
DemandRebrandingPermission();
@ -2219,6 +2219,8 @@ namespace ASC.Api.Settings
settings.FooterEnabled = footerEnabled;
SettingsManager.SaveForDefaultTenant(settings);
return true;
}
///<visible>false</visible>
@ -2460,7 +2462,8 @@ namespace ASC.Api.Settings
.AddEncryptionServiceNotifierService()
.AddTelegramLoginProviderService()
.AddTelegramHelperSerivce()
.AddPasswordHasherService();
.AddPasswordHasherService()
.AddBackupAjaxHandler();
}
}
}

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace ASC.Web.Api.Models
{

View File

@ -8,9 +8,12 @@ namespace ASC.Web.Api.Models
{
public class WhiteLabelModel
{
public IEnumerable<IFormFile> Attachments { get; set; }
public string LogoText { get; set; }
public IEnumerable<ItemKeyValuePair<int, string>> Logo { get; set; }
public IEnumerable<ItemKeyValuePair<string, string>> Logo { get; set; }
}
public class WhiteLabelQuery
{
public bool IsDefault { get; set; }
public bool IsRetina { get; set; }
}

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -18,6 +20,7 @@ namespace ASC.Web.Api
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

View File

@ -3,9 +3,9 @@ using ASC.Api.Core;
using ASC.Api.Settings;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Web.Api.Controllers;
using ASC.Web.Api.Controllers;
using Autofac.Extensions.DependencyInjection;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -27,7 +27,9 @@ namespace ASC.Web.Api
{
base.ConfigureServices(services);
services.AddMemoryCache();
services.AddMemoryCache();
services.AddOptions();
DIHelper
.AddAuthenticationController()
@ -35,10 +37,12 @@ namespace ASC.Web.Api
.AddPortalController()
.AddSettingsController()
.AddSecurityController()
.AddSmtpSettingsController();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
.AddSmtpSettingsController();
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
}
}

View File

@ -19,7 +19,7 @@
<meta name="mobile-web-app-capable" content="yes" />
<!-- Tell iOS it's a PWA -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="icon.png" />
<link rel="apple-touch-icon" href="appIcon.png" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i"
rel="stylesheet"

View File

@ -35,7 +35,6 @@ using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Notify.Engine;
using ASC.Core;
using ASC.Core.Common;
using ASC.Core.Common.Settings;
using ASC.Core.Tenants;
using ASC.Core.Users;

View File

@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Web;
using System.Linq;
using ASC.Common;
using ASC.Common.Caching;
@ -11,8 +9,6 @@ using ASC.Notify.Recipients;
using ASC.Web.Studio.Core.Notify;
using ASC.Web.Studio.Utility;
using Microsoft.AspNetCore.Http;
namespace ASC.Web.Core.Notify
{
public class StudioNotifyServiceHelper

View File

@ -163,9 +163,18 @@ namespace ASC.Web.Core.Users
public class CustomNamingPeople
{
private static object Locked;
private static bool loaded = false;
private static readonly List<PeopleNamesItem> items = new List<PeopleNamesItem>();
private SettingsManager SettingsManager { get; }
static CustomNamingPeople()
{
Locked = new object();
loaded = false;
items = new List<PeopleNamesItem>();
}
public CustomNamingPeople(SettingsManager settingsManager)
{
@ -183,9 +192,6 @@ namespace ASC.Web.Core.Users
}
}
public PeopleNamesSettings PeopleNamesSettings { get; }
private SettingsManager SettingsManager { get; }
public string Substitute<T>(string resourceKey) where T : class
{
var text = (string)typeof(T).GetProperty(resourceKey, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null, null);
@ -257,28 +263,36 @@ namespace ASC.Web.Core.Users
return;
}
loaded = true;
var doc = new XmlDocument();
doc.LoadXml(NamingPeopleResource.PeopleNames);
items.Clear();
foreach (XmlNode node in doc.SelectNodes("/root/item"))
lock (Locked)
{
var item = new PeopleNamesItem
if (loaded)
{
Id = node.SelectSingleNode("id").InnerText,
SchemaName = node.SelectSingleNode("names/schemaname").InnerText,
GroupHeadCaption = node.SelectSingleNode("names/grouphead").InnerText,
GroupCaption = node.SelectSingleNode("names/group").InnerText,
GroupsCaption = node.SelectSingleNode("names/groups").InnerText,
UserCaption = node.SelectSingleNode("names/user").InnerText,
UsersCaption = node.SelectSingleNode("names/users").InnerText,
UserPostCaption = node.SelectSingleNode("names/userpost").InnerText,
RegDateCaption = node.SelectSingleNode("names/regdate").InnerText,
GuestCaption = node.SelectSingleNode("names/guest").InnerText,
GuestsCaption = node.SelectSingleNode("names/guests").InnerText,
};
items.Add(item);
return;
}
loaded = true;
var doc = new XmlDocument();
doc.LoadXml(NamingPeopleResource.PeopleNames);
items.Clear();
foreach (XmlNode node in doc.SelectNodes("/root/item"))
{
var item = new PeopleNamesItem
{
Id = node.SelectSingleNode("id").InnerText,
SchemaName = node.SelectSingleNode("names/schemaname").InnerText,
GroupHeadCaption = node.SelectSingleNode("names/grouphead").InnerText,
GroupCaption = node.SelectSingleNode("names/group").InnerText,
GroupsCaption = node.SelectSingleNode("names/groups").InnerText,
UserCaption = node.SelectSingleNode("names/user").InnerText,
UsersCaption = node.SelectSingleNode("names/users").InnerText,
UserPostCaption = node.SelectSingleNode("names/userpost").InnerText,
RegDateCaption = node.SelectSingleNode("names/regdate").InnerText,
GuestCaption = node.SelectSingleNode("names/guest").InnerText,
GuestsCaption = node.SelectSingleNode("names/guests").InnerText,
};
items.Add(item);
}
}
}

View File

@ -117,7 +117,7 @@ namespace ASC.Web.Core
}
}
public WebItemManager(IContainer container, IConfiguration configuration, IOptionsMonitor<ILog> options)
public WebItemManager(ILifetimeScope container, IConfiguration configuration, IOptionsMonitor<ILog> options)
{
Container = container;
Configuration = configuration;
@ -126,13 +126,6 @@ namespace ASC.Web.Core
LoadItems();
}
public WebItemManager(ILifetimeScope container, IConfiguration configuration, IOptionsMonitor<ILog> options)
: this(null, configuration, options)
{
Container = container;
LoadItems();
}
public void LoadItems()
{
if (Container == null) return;

View File

@ -35,6 +35,11 @@ using Microsoft.Extensions.DependencyInjection;
namespace ASC.Web.Core.WhiteLabel
{
public class AdditionalWhiteLabelSettingsWrapper
{
public AdditionalWhiteLabelSettings Settings { get; set; }
}
[Serializable]
public class AdditionalWhiteLabelSettings : ISettings
{

View File

@ -34,7 +34,12 @@ using Microsoft.Extensions.DependencyInjection;
namespace ASC.Web.Core.WhiteLabel
{
{
public class CompanyWhiteLabelSettingsWrapper
{
public CompanyWhiteLabelSettings Settings { get; set; }
}
[Serializable]
public class CompanyWhiteLabelSettings : ISettings
{

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -17,6 +19,7 @@ namespace ASC.Web.Studio
public static IHostBuilder CreateWebHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(w =>
{
w.UseStartup<Startup>();
@ -33,7 +36,7 @@ namespace ASC.Web.Studio
config
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path}
{"pathToConf", path}
})
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)

View File

@ -6,6 +6,8 @@ using ASC.Data.Storage.Configuration;
using ASC.Data.Storage.DiscStorage;
using ASC.FederatedLogin;
using Autofac;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
@ -37,15 +39,16 @@ namespace ASC.Web.Studio
.AddStorageHandlerService()
.AddLoginHandlerService();
services.AddMemoryCache();
services.AddMemoryCache();
}
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}
public void ConfigureContainer(ContainerBuilder builder)
{
builder.Register(Configuration, HostEnvironment.ContentRootPath);
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto