diff --git a/Security/DependencyInjection.cs b/Security/DependencyInjection.cs index aa36553..dc87c7d 100644 --- a/Security/DependencyInjection.cs +++ b/Security/DependencyInjection.cs @@ -61,7 +61,7 @@ public static class DependencyInjection providers.Add(provider, (clientId, secret)); } - services.AddSingleton(provider => new OAuthService(provider.GetRequiredService>(), providers)); + services.AddSingleton(provider => new OAuthService(provider.GetRequiredService>(), providers, configuration["SECURITY_ENCRYPTION_TOKEN"]!)); return services; } diff --git a/Security/Services/OAuthService.cs b/Security/Services/OAuthService.cs index b23d9da..b2ef0ee 100644 --- a/Security/Services/OAuthService.cs +++ b/Security/Services/OAuthService.cs @@ -10,13 +10,15 @@ using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Security; +using System.Security.Cryptography; +using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; namespace Mirea.Api.Security.Services; -public class OAuthService(ILogger logger, Dictionary providers) +public class OAuthService(ILogger logger, Dictionary providers, string secretKey) { private static readonly Dictionary ProviderData = new() { @@ -97,6 +99,12 @@ public class OAuthService(ILogger logger, Dictionary logger, Dictionary logger, Dictionary LoginOAuth(HttpContext context, CookieOptionsParameters cookieOptions, string redirectUrl, string code, string state, CancellationToken cancellation = default) { - var requestContext = new RequestContextInfo(context, cookieOptions); - var partsState = state.Split('_'); if (!Enum.TryParse(partsState.Last(), true, out var provider) || @@ -133,9 +139,10 @@ public class OAuthService(ILogger logger, Dictionary