Skip to content

Commit ab8804a

Browse files
authored
Fixed logging
1 parent e602a73 commit ab8804a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Jellyfin.HardwareVisualizer/Server/Services/SubmitToken/SubmitTokenService.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ public class SubmitTokenService : ISubmitTokenService
1212
{
1313
private readonly IHttpContextAccessor _httpContextAccessor;
1414
private readonly IMemoryCache _memoryCache;
15-
16-
private readonly byte[] _key;
15+
private readonly ILogger<SubmitTokenService> _logger;
16+
private readonly byte[] _key;
1717
private readonly byte[] _iv;
1818

19-
public SubmitTokenService(IHttpContextAccessor httpContextAccessor, IMemoryCache memoryCache)
19+
public SubmitTokenService(IHttpContextAccessor httpContextAccessor, IMemoryCache memoryCache, ILogger<SubmitTokenService> logger)
2020
{
2121
_httpContextAccessor = httpContextAccessor;
2222
_memoryCache = memoryCache;
23+
_logger = logger;
2324

24-
25-
// Create a new DES object to generate a random _key
26-
// and initialization vector (IV).
27-
using (DES des = DES.Create())
25+
// Create a new DES object to generate a random _key
26+
// and initialization vector (IV).
27+
using (DES des = DES.Create())
2828
{
2929
_key = des.Key;
3030
_iv = des.IV;
@@ -73,6 +73,8 @@ public bool Validate(JwtPayload token, out TimeSpan? retryAfter)
7373
{
7474
var ipAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
7575

76+
_logger.LogInformation($"Ip {ipAddress} requested a new Token.");
77+
7678
var cacheKey = "ip-token-" + ipAddress;
7779
if (_memoryCache.TryGetValue<TokenStore>(cacheKey, out var tokenStore)
7880
&& tokenStore.JwtPayload.ValidTo > DateTime.UtcNow)
@@ -85,7 +87,7 @@ public bool Validate(JwtPayload token, out TimeSpan? retryAfter)
8587
return (Encrypt(tokenStore.JwtPayload), null);
8688
}
8789

88-
var expiresAt = DateTime.UtcNow.AddHours(10);
90+
var expiresAt = DateTime.UtcNow.AddHours(4);
8991
tokenStore = new TokenStore();
9092
tokenStore.JwtPayload = new JwtPayload("jhwa/server", "jhwa/client", [new Claim("ip", ipAddress)],
9193
DateTime.UtcNow, expiresAt, DateTime.UtcNow);

Jellyfin.HardwareVisualizer/Server/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"Logging": {
33
"LogLevel": {
44
"Default": "Information",
5-
"Microsoft.AspNetCore": "Warning"
5+
"Microsoft.AspNetCore": "Warning",
6+
"Microsoft.EntityFrameworkCore.Database": "None"
67
}
78
},
89
"AllowedHosts": "*",

0 commit comments

Comments
 (0)