diff --git a/Security/Common/Domain/Caching/OAuthUserExtension.cs b/Security/Common/Domain/Caching/OAuthUserExtension.cs new file mode 100644 index 0000000..344663b --- /dev/null +++ b/Security/Common/Domain/Caching/OAuthUserExtension.cs @@ -0,0 +1,9 @@ +namespace Mirea.Api.Security.Common.Domain.Caching; + +internal class OAuthUserExtension +{ + public string? Message { get; set; } + public bool IsSuccess { get; set; } + public required OAuthProvider? Provider { get; set; } + public OAuthUser? User { get; set; } +} \ No newline at end of file diff --git a/Security/Services/OAuthService.cs b/Security/Services/OAuthService.cs index cc0c3dc..506ce72 100644 --- a/Security/Services/OAuthService.cs +++ b/Security/Services/OAuthService.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Mirea.Api.Security.Common.Domain; +using Mirea.Api.Security.Common.Domain.Caching; using Mirea.Api.Security.Common.Interfaces; using Mirea.Api.Security.Common.OAuth2; using Mirea.Api.Security.Common.OAuth2.UserInfo; @@ -11,6 +12,7 @@ using System.IO; 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; @@ -166,7 +168,14 @@ public class OAuthService(ILogger logger, Dictionary + cache.SetAsync( + key, + JsonSerializer.SerializeToUtf8Bytes(data), + slidingExpiration: TimeSpan.FromMinutes(15), + cancellationToken: cancellation); + + public Uri GetProviderRedirect(HttpContext context, CookieOptions cookieOptions, string redirectUri, OAuthProvider provider, Uri callback) { @@ -205,17 +214,30 @@ public class OAuthService(ILogger logger, Dictionary logger, Dictionary logger, Dictionary logger, Dictionary logger, Dictionary logger, Dictionary logger, Dictionary