mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Implement user session management and JWT refresh tokens
Added user session models, interfaces, repository, and service for managing user sessions and refresh tokens. Refactored authentication flow to return user objects and open sessions with device info, supporting refresh token generation and validation. Updated JWT configuration to separate access and refresh options, and refactored related tests and API contracts. Improved media upload handling and error logging. Migrated dependency references and DI registrations accordingly.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces.Authentication;
|
||||
|
||||
public interface IAccountService
|
||||
{
|
||||
public Task<string> RegistrationAsync(string name, string password, Invitation invitation);
|
||||
public Task<string> LoginAsync(string name, string password);
|
||||
public Task<User> RegistrationAsync(string name, string password, Invitation invitation);
|
||||
public Task<User> LoginAsync(string name, string password);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.API.Services.Authentication.Interfaces;
|
||||
namespace Govor.Application.Interfaces.Authentication;
|
||||
|
||||
public interface IInvitesService
|
||||
{
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System.Security.Claims;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces.Authentication;
|
||||
|
||||
public interface IJwtService
|
||||
{
|
||||
Task<string> GenerateJwtTokenAsync(User user);
|
||||
Task<string> GenerateAccessTokenAsync(User user);
|
||||
Task<string> GenerateRefreshTokenAsync(User user);
|
||||
ClaimsPrincipal GetPrincipalFromExpiredToken(string token);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Govor.API.Services.AdminsStuff.Interfaces;
|
||||
namespace Govor.Application.Interfaces;
|
||||
|
||||
public interface IInvitationGenerator
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ public interface IMediaService
|
||||
|
||||
public record Media(Guid UploaderId,
|
||||
DateTime UploadedOn,
|
||||
byte[] Data,
|
||||
string FileName,
|
||||
byte[] Data,
|
||||
MediaType Type,
|
||||
string MineType,
|
||||
string EncryptedKey);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces.UserSession;
|
||||
|
||||
|
||||
public interface IUserSessionOpener
|
||||
{
|
||||
Task<string> OpenSessionAsync(User user, string deviceInfo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Govor.Application.Interfaces.UserSession;
|
||||
|
||||
public interface IUserSessionReader
|
||||
{
|
||||
Task<List<Core.Models.UserSession>> GetAllSessionsAsync(Guid userId);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Govor.Application.Interfaces.UserSession;
|
||||
|
||||
|
||||
public interface IUserSessionRevoker
|
||||
{
|
||||
Task CloseSessionByRefreshTokenAsync(string refreshToken);
|
||||
Task CloseAllSessionsAsync(Guid userId);
|
||||
}
|
||||
Reference in New Issue
Block a user