Add hashing and other security features #12
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Mirea.Api.Security.Services;
|
namespace Mirea.Api.Security.Services;
|
||||||
|
|
||||||
public class AuthService(ICacheService cache, IAccessToken accessTokenService)
|
public class AuthService(ICacheService cache, IAccessToken accessTokenService, IRevokedToken revokedToken)
|
||||||
{
|
{
|
||||||
public TimeSpan Lifetime { private get; init; }
|
public TimeSpan Lifetime { private get; init; }
|
||||||
|
|
||||||
@ -28,6 +28,9 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService)
|
|||||||
slidingExpiration: Lifetime,
|
slidingExpiration: Lifetime,
|
||||||
cancellationToken: cancellation);
|
cancellationToken: cancellation);
|
||||||
|
|
||||||
|
private Task RevokeAccessToken(string token) =>
|
||||||
|
revokedToken.AddTokenToRevokedAsync(token, accessTokenService.GetExpireDateTime(token));
|
||||||
|
|
||||||
public async Task<AuthTokenResponse> GenerateAuthTokensAsync(TokenRequest request, string preAuthToken, CancellationToken cancellation = default)
|
public async Task<AuthTokenResponse> GenerateAuthTokensAsync(TokenRequest request, string preAuthToken, CancellationToken cancellation = default)
|
||||||
{
|
{
|
||||||
string userId = await new PreAuthService(cache).MatchToken(request, preAuthToken, cancellation);
|
string userId = await new PreAuthService(cache).MatchToken(request, preAuthToken, cancellation);
|
||||||
|
Loading…
Reference in New Issue
Block a user