2024-06-01 10:57:52 +03:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Mirea.Api.Endpoint.Common.Services.Security;
|
2024-06-01 11:10:42 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Configuration.General;
|
2024-06-01 10:57:52 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
|
|
|
|
using Mirea.Api.Security;
|
|
|
|
|
using Mirea.Api.Security.Common.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
|
|
|
|
|
|
|
|
|
public static class SecureConfiguration
|
|
|
|
|
{
|
|
|
|
|
public static IServiceCollection AddSecurity(this IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
services.AddSecurityServices(configuration);
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IRevokedToken, MemoryRevokedTokenService>();
|
|
|
|
|
|
2024-06-01 11:10:42 +03:00
|
|
|
|
if (configuration.Get<GeneralConfig>()?.CacheSettings?.TypeDatabase == CacheSettings.CacheEnum.Redis)
|
2024-06-01 10:57:52 +03:00
|
|
|
|
services.AddSingleton<ICacheService, DistributedCacheService>();
|
|
|
|
|
else
|
|
|
|
|
services.AddSingleton<ICacheService, MemoryCacheService>();
|
|
|
|
|
|
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
}
|