Add Application configuration #11
@ -1,8 +1,12 @@
|
|||||||
using System;
|
using Mirea.Api.Security.Common.Domain;
|
||||||
|
using Mirea.Api.Security.Common.Dto.Requests;
|
||||||
|
using Mirea.Api.Security.Common.Dto.Responses;
|
||||||
|
using Mirea.Api.Security.Common.Interfaces;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Mirea.Api.Security.Services;
|
namespace Mirea.Api.Security.Services;
|
||||||
|
|
||||||
public class AuthService()
|
public class AuthService(ICacheService cache)
|
||||||
{
|
{
|
||||||
public TimeSpan Lifetime { private get; init; }
|
public TimeSpan Lifetime { private get; init; }
|
||||||
|
|
||||||
@ -10,4 +14,11 @@ public class AuthService()
|
|||||||
GeneratorKey.GenerateString(32);
|
GeneratorKey.GenerateString(32);
|
||||||
|
|
||||||
private static string GetAuthCacheKey(string fingerprint) => $"{fingerprint}_auth_token";
|
private static string GetAuthCacheKey(string fingerprint) => $"{fingerprint}_auth_token";
|
||||||
|
|
||||||
|
private Task SetAuthTokenDataToCache(string fingerprint, AuthToken data, CancellationToken cancellation) =>
|
||||||
|
cache.SetAsync(
|
||||||
|
GetAuthCacheKey(fingerprint),
|
||||||
|
JsonSerializer.SerializeToUtf8Bytes(data),
|
||||||
|
slidingExpiration: Lifetime,
|
||||||
|
cancellationToken: cancellation);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user