Implement refresh token flow and refactor session handling

Added refresh token endpoint and controller, introduced IUserSessionRefresher and UserSessionRefresher for token renewal, and updated session handling to return both access and refresh tokens. Refactored AuthController, tests, and related interfaces to support new token flow. Fixed JwtAccessOption property typo, updated configuration, and extended UserSessionsRepository to support lookup by refresh token.
This commit is contained in:
Artemy
2025-07-19 17:51:06 +07:00
parent ab643c16a4
commit ff873ae179
25 changed files with 485 additions and 124 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ public class UserSession
public Guid Id { get; set; } = Guid.NewGuid();
public Guid UserId { get; set; }
public string RefreshToken { get; set; } = string.Empty;
public string DeviceInfo { get; set; } = string.Empty; // например, "Chrome on Windows"
public string DeviceInfo { get; set; } = string.Empty; // "Chrome on Windows"
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime ExpiresAt { get; set; }
public bool IsRevoked { get; set; } = false;
@@ -10,4 +10,5 @@ public interface IUserSessionsReader
public Task<List<UserSession>> GetByCreatedAtAsync(DateTime createdAt);
public Task<List<UserSession>> GetByExpiresAtAsync(DateTime createdAt);
public Task<List<UserSession>> GetByRevokedAsync(bool isRevoked);
public Task<UserSession> GetByRefreshTokenAsync(string refreshToken);
}