feat: add auth service to DI

This commit is contained in:
Polianin Nikita 2024-05-29 06:04:09 +03:00
parent 25b6c7d691
commit 2efdc6dbfe

View File

@ -26,7 +26,7 @@ public static class DependencyInjection
Secret = configuration["SECURITY_HASH_TOKEN"] Secret = configuration["SECURITY_HASH_TOKEN"]
}); });
var lifeTimeLogin = TimeSpan.FromMinutes(int.Parse(configuration["SECURITY_LIFE_TIME_1_FA"]!)); var lifeTimePreAuthToken = TimeSpan.FromMinutes(int.Parse(configuration["SECURITY_LIFE_TIME_1_FA"]!));
services.AddSingleton(provider => services.AddSingleton(provider =>
{ {
@ -34,7 +34,21 @@ public static class DependencyInjection
return new PreAuthService(cache) return new PreAuthService(cache)
{ {
Lifetime = lifeTimeLogin Lifetime = lifeTimePreAuthToken
};
});
var lifeTimeRefreshToken = TimeSpan.FromMinutes(int.Parse(configuration["SECURITY_LIFE_TIME_RT"]!));
services.AddSingleton(provider =>
{
var cacheService = provider.GetRequiredService<ICacheService>();
var accessTokenService = provider.GetRequiredService<IAccessToken>();
var revokedTokenService = provider.GetRequiredService<IRevokedToken>();
return new AuthService(cacheService, accessTokenService, revokedTokenService)
{
Lifetime = lifeTimeRefreshToken
}; };
}); });