mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
namespace Govor.Application.Services.Authentication;
|
||||
public class JwtAccessOption
|
||||
{
|
||||
public string SecretKeу {get; set;}
|
||||
public string SecretKey {get; set;}
|
||||
public int Minutes { get; set; }
|
||||
}
|
||||
@@ -3,4 +3,4 @@ namespace Govor.Application.Services.Authentication;
|
||||
public class JwtRefreshOption
|
||||
{
|
||||
public int RefreshTokenLifetimeDays { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class JwtService : IJwtService
|
||||
};
|
||||
|
||||
var singing = new SigningCredentials(
|
||||
new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKeу)),
|
||||
new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKey)),
|
||||
SecurityAlgorithms.HmacSha256Signature);
|
||||
|
||||
var token = new JwtSecurityToken(
|
||||
@@ -43,7 +43,7 @@ public class JwtService : IJwtService
|
||||
|
||||
public async Task<string> GenerateRefreshTokenAsync(User user)
|
||||
{
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKeу));
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKey));
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||
|
||||
var claims = new[]
|
||||
@@ -68,7 +68,7 @@ public class JwtService : IJwtService
|
||||
ValidateAudience = false,
|
||||
ValidateIssuer = false,
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKeу)),
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtAccessOption.SecretKey)),
|
||||
ValidateLifetime = false // << important
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user