aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Session
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2022-10-07 09:04:41 +0200
committerShadowghost <Ghost_of_Stone@web.de>2022-10-07 09:16:02 +0200
commit7b90fcd0531e1fd414df404b58f2f05b0641be01 (patch)
tree9cb45933f68308a9dca1e6217318742f3ef7f9d6 /Emby.Server.Implementations/Session
parentbd9a940fed129d99fe9ffedafec324e795549c90 (diff)
parent719e5eae16a3488de449a5b2a7c56132c8f1e5c1 (diff)
Merge branch 'master' into network-rewrite
Diffstat (limited to 'Emby.Server.Implementations/Session')
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs35
-rw-r--r--Emby.Server.Implementations/Session/SessionWebSocketListener.cs16
2 files changed, 12 insertions, 39 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 7f927e270..0d1029882 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -665,10 +665,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var session = GetSession(info.SessionId);
@@ -762,10 +759,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var session = GetSession(info.SessionId);
@@ -897,10 +891,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
@@ -1341,15 +1332,9 @@ namespace Emby.Server.Implementations.Session
private static void AssertCanControl(SessionInfo session, SessionInfo controllingSession)
{
- if (session == null)
- {
- throw new ArgumentNullException(nameof(session));
- }
+ ArgumentNullException.ThrowIfNull(session);
- if (controllingSession == null)
- {
- throw new ArgumentNullException(nameof(controllingSession));
- }
+ ArgumentNullException.ThrowIfNull(controllingSession);
}
/// <summary>
@@ -1688,10 +1673,7 @@ namespace Emby.Server.Implementations.Session
/// </summary>
private BaseItemDto GetItemInfo(BaseItem item, MediaSourceInfo mediaSource)
{
- if (item == null)
- {
- throw new ArgumentNullException(nameof(item));
- }
+ ArgumentNullException.ThrowIfNull(item);
var dtoOptions = _itemInfoDtoOptions;
@@ -1802,10 +1784,7 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc />
public Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion)
{
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
+ ArgumentNullException.ThrowIfNull(info);
var user = info.UserId.Equals(default)
? null
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index 35fd5caae..c654828b1 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Api.Extensions;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Net;
@@ -53,7 +54,6 @@ namespace Emby.Server.Implementations.Session
private readonly ISessionManager _sessionManager;
private readonly ILogger<SessionWebSocketListener> _logger;
private readonly ILoggerFactory _loggerFactory;
- private readonly IAuthorizationContext _authorizationContext;
/// <summary>
/// The KeepAlive cancellation token.
@@ -66,17 +66,14 @@ namespace Emby.Server.Implementations.Session
/// <param name="logger">The logger.</param>
/// <param name="sessionManager">The session manager.</param>
/// <param name="loggerFactory">The logger factory.</param>
- /// <param name="authorizationContext">The authorization context.</param>
public SessionWebSocketListener(
ILogger<SessionWebSocketListener> logger,
ISessionManager sessionManager,
- ILoggerFactory loggerFactory,
- IAuthorizationContext authorizationContext)
+ ILoggerFactory loggerFactory)
{
_logger = logger;
_sessionManager = sessionManager;
_loggerFactory = loggerFactory;
- _authorizationContext = authorizationContext;
}
/// <inheritdoc />
@@ -110,21 +107,18 @@ namespace Emby.Server.Implementations.Session
private async Task<SessionInfo> GetSession(HttpContext httpContext, string remoteEndpoint)
{
- var authorizationInfo = await _authorizationContext.GetAuthorizationInfo(httpContext)
- .ConfigureAwait(false);
-
- if (!authorizationInfo.IsAuthenticated)
+ if (!httpContext.User.Identity?.IsAuthenticated ?? false)
{
return null;
}
- var deviceId = authorizationInfo.DeviceId;
+ var deviceId = httpContext.User.GetDeviceId();
if (httpContext.Request.Query.TryGetValue("deviceId", out var queryDeviceId))
{
deviceId = queryDeviceId;
}
- return await _sessionManager.GetSessionByAuthenticationToken(authorizationInfo.Token, deviceId, remoteEndpoint)
+ return await _sessionManager.GetSessionByAuthenticationToken(httpContext.User.GetToken(), deviceId, remoteEndpoint)
.ConfigureAwait(false);
}