aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2022-10-07 07:49:46 +0200
committerGitHub <noreply@github.com>2022-10-07 07:49:46 +0200
commit803972a76f6f8eb590b2de06662f7e83ce40273d (patch)
treedd72f47907390a7a88373d4cc7510d602ed2d556 /Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
parent927fe33d3a0ec7f9e0fb568cfd423c6e8b966c9d (diff)
parent6afc9110439c3c5345beb9a6bac1968ee4dedce8 (diff)
Merge pull request #8500 from cvium/fix_authcontext_usage
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/Security/SessionContext.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/SessionContext.cs59
1 files changed, 0 insertions, 59 deletions
diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
deleted file mode 100644
index e0d20e210..000000000
--- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma warning disable CS1591
-
-using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Net;
-using MediaBrowser.Controller.Session;
-using Microsoft.AspNetCore.Http;
-
-namespace Emby.Server.Implementations.HttpServer.Security
-{
- public class SessionContext : ISessionContext
- {
- private readonly IUserManager _userManager;
- private readonly ISessionManager _sessionManager;
- private readonly IAuthorizationContext _authContext;
-
- public SessionContext(IUserManager userManager, IAuthorizationContext authContext, ISessionManager sessionManager)
- {
- _userManager = userManager;
- _authContext = authContext;
- _sessionManager = sessionManager;
- }
-
- public async Task<SessionInfo> GetSession(HttpContext requestContext)
- {
- var authorization = await _authContext.GetAuthorizationInfo(requestContext).ConfigureAwait(false);
-
- var user = authorization.User;
- return await _sessionManager.LogSessionActivity(
- authorization.Client,
- authorization.Version,
- authorization.DeviceId,
- authorization.Device,
- requestContext.GetNormalizedRemoteIp().ToString(),
- user).ConfigureAwait(false);
- }
-
- public Task<SessionInfo> GetSession(object requestContext)
- {
- return GetSession((HttpContext)requestContext);
- }
-
- public async Task<User?> GetUser(HttpContext requestContext)
- {
- var session = await GetSession(requestContext).ConfigureAwait(false);
-
- return session.UserId.Equals(default)
- ? null
- : _userManager.GetUserById(session.UserId);
- }
-
- public Task<User?> GetUser(object requestContext)
- {
- return GetUser(((HttpRequest)requestContext).HttpContext);
- }
- }
-}