aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Security
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server.Implementations/Security')
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthenticationManager.cs8
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthorizationContext.cs13
2 files changed, 16 insertions, 5 deletions
diff --git a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
index ab76e2302f..b79e46469c 100644
--- a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Data.Entities.Security;
@@ -43,7 +41,7 @@ namespace Jellyfin.Server.Implementations.Security
.Select(key => new AuthenticationInfo
{
AppName = key.Name,
- AccessToken = key.AccessToken.ToString("N", CultureInfo.InvariantCulture),
+ AccessToken = key.AccessToken,
DateCreated = key.DateCreated,
DeviceId = string.Empty,
DeviceName = string.Empty,
@@ -52,7 +50,7 @@ namespace Jellyfin.Server.Implementations.Security
}
/// <inheritdoc />
- public async Task DeleteApiKey(Guid accessToken)
+ public async Task DeleteApiKey(string accessToken)
{
await using var dbContext = _dbProvider.CreateContext();
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index e589fae301..9a073c4770 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -187,6 +187,19 @@ namespace Jellyfin.Server.Implementations.Security
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
}
+ else
+ {
+ var key = await dbContext.ApiKeys.FirstOrDefaultAsync(apiKey => apiKey.AccessToken == token).ConfigureAwait(false);
+ if (key != null)
+ {
+ authInfo.IsAuthenticated = true;
+ authInfo.Client = key.Name;
+ authInfo.Token = key.AccessToken;
+ authInfo.DeviceId = string.Empty;
+ authInfo.Device = string.Empty;
+ authInfo.Version = string.Empty;
+ }
+ }
return authInfo;
}