Release v1.0.0 #16

Merged
Wesser merged 492 commits from release/v1.0.0 into master 2025-02-12 09:19:32 +03:00
256 changed files with 13012 additions and 98 deletions
Showing only changes of commit 3811d879ab - Show all commits

View File

@ -7,6 +7,7 @@ using Mirea.Api.Dto.Common;
using Mirea.Api.Dto.Requests; using Mirea.Api.Dto.Requests;
using Mirea.Api.Endpoint.Common.Attributes; using Mirea.Api.Endpoint.Common.Attributes;
using Mirea.Api.Endpoint.Common.Exceptions; using Mirea.Api.Endpoint.Common.Exceptions;
using Mirea.Api.Endpoint.Common.MapperDto;
using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Common.Services;
using Mirea.Api.Endpoint.Configuration.Model; using Mirea.Api.Endpoint.Configuration.Model;
using Mirea.Api.Security.Common.Domain; using Mirea.Api.Security.Common.Domain;
@ -50,7 +51,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
}, },
HttpContext, request.Password); HttpContext, request.Password);
return Ok(tokenResult ? TwoFactorAuthentication.None : TwoFactorAuthentication.TotpRequired); return Ok(tokenResult.ConvertToDto());
} }
[HttpGet("Login")] [HttpGet("Login")]

View File

@ -121,7 +121,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
return true; return true;
} }
public async Task<bool> LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, CancellationToken cancellation = default) public async Task<TwoFactorAuthenticator> LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, CancellationToken cancellation = default)
{ {
var requestContext = new RequestContextInfo(context, cookieOptions); var requestContext = new RequestContextInfo(context, cookieOptions);
@ -130,7 +130,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
if (user.TwoFactorAuthenticator == TwoFactorAuthenticator.None) if (user.TwoFactorAuthenticator == TwoFactorAuthenticator.None)
{ {
await GenerateAuthTokensAsync(cookieOptions, context, requestContext, user.Id.ToString(), cancellation); await GenerateAuthTokensAsync(cookieOptions, context, requestContext, user.Id.ToString(), cancellation);
return true; return TwoFactorAuthenticator.None;
} }
var firstAuthToken = new FirstAuthToken(requestContext) var firstAuthToken = new FirstAuthToken(requestContext)
@ -142,7 +142,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
await cache.SetAsync(GetFirstAuthCacheKey(requestContext.Fingerprint), firstAuthToken, absoluteExpirationRelativeToNow: LifetimeFirstAuth, cancellationToken: cancellation); await cache.SetAsync(GetFirstAuthCacheKey(requestContext.Fingerprint), firstAuthToken, absoluteExpirationRelativeToNow: LifetimeFirstAuth, cancellationToken: cancellation);
return false; return user.TwoFactorAuthenticator;
} }
public async Task RefreshTokenAsync(CookieOptionsParameters cookieOptions, HttpContext context, CancellationToken cancellation = default) public async Task RefreshTokenAsync(CookieOptionsParameters cookieOptions, HttpContext context, CancellationToken cancellation = default)