Files
duplicati/Duplicati/WebserverCore/Extensions/ServiceCollectionsExtensions.cs
T
Kenneth Skovhede 3f29642f6c Implemented JWT tokens.
Added auth requirement on all endpoints.
Added SignIn-, Access- and Refresh-Tokens based on JWT.
Upgraded stored password to be based on PBKDF2.
Added default password assignment.
Updated logic to support auth-header and re-sign-in for tray-icon and web-ui.
2024-06-19 13:54:10 +02:00

52 lines
2.1 KiB
C#

using Duplicati.Library.IO;
using Duplicati.Library.RestAPI;
using Duplicati.Library.RestAPI.Abstractions;
using Duplicati.Server;
using Duplicati.Server.Database;
using Duplicati.Server.Serialization;
using Duplicati.WebserverCore.Abstractions;
using Duplicati.WebserverCore.Abstractions.Notifications;
using Duplicati.WebserverCore.Middlewares;
using Duplicati.WebserverCore.Notifications;
using Duplicati.WebserverCore.Services;
using Duplicati.WebserverCore.Services.Settings;
using WebserverCore.Services;
namespace Duplicati.WebserverCore.Extensions;
public static class ServiceCollectionsExtensions
{
public static IServiceCollection AddDuplicati(this IServiceCollection services, Connection connection)
{
//old part
services
.AddSingleton<LiveControls>()
.AddSingleton(Serializer.JsonSettings)
.AddSingleton<UpdatePollThread>()
.AddSingleton<EventPollNotify>()
.AddSingleton<Scheduler>()
.AddSingleton(connection);
//transitional part - services that act as a proxy to old part for various reasons (not accessible in assembly i.e.)
services.AddSingleton<ILiveControls>(c => c.GetRequiredService<LiveControls>());
//new part
services
.AddSingleton<ISettingsService, SettingsService>()
.AddTransient<IStatusService, StatusService>()
.AddTransient<IUpdateService, UpdateService>()
.AddSingleton<INotificationUpdateService, NotificationUpdateService>()
.AddSingleton<IWorkerThreadsManager, WorkerThreadsManager>()
.AddSingleton<IScheduler, SchedulerService>()
.AddSingleton<IWebsocketAccessor, WebsocketAccessor>()
.AddTransient<ILanguageService, LanguageService>()
.AddSingleton<ICaptchaProvider, CaptchaService>()
.AddSingleton<ICommandlineRunService, CommandlineRunService>()
.AddTransient<IJWTTokenProvider, JWTTokenProvider>()
.AddTransient<ITokenFamilyStore, TokenFamilyStore>()
.AddTransient<ILoginProvider, LoginProvider>();
return services;
}
}