diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 1c7b80e..e78ce75 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -227,7 +227,30 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I requestContext.Ip); throw new SecurityException(defaultMessageError); + } + if (authToken.UserAgent != requestContext.UserAgent) + { + logger.LogInformation("The resulting User-Agent {ProvidedUserAgent} does not match the cached " + + "{ExpectedUserAgent} of the user {UserId} with the fingerprint {Fingerprint}.", + requestContext.UserAgent, + authToken.UserAgent, + authToken.UserId, + requestContext.Fingerprint); + + authToken.UserAgent = requestContext.UserAgent; + } + + if (authToken.Ip != requestContext.Ip) + { + logger.LogInformation("The resulting Ip {ProvidedIp} does not match the cached " + + "{ExpectedIp} of the user {UserId} with the fingerprint {Fingerprint}.", + requestContext.Ip, + authToken.Ip, + authToken.UserId, + requestContext.Fingerprint); + + authToken.Ip = requestContext.Ip; } var (token, expireIn) = GenerateAccessToken(authToken.UserId);