From 4edcab9c11cf8e8cfbfc0bd9afe7b7ec067fd1e3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 15 Nov 2014 10:51:49 -0500 Subject: [PATCH] updated service stack --- .../HttpServer/Security/AuthService.cs | 17 ++++++++++++++++- .../SocketSharp/WebSocketSharpResponse.cs | 2 ++ .../MediaBrowser.Server.Implementations.csproj | 5 +---- .../ApplicationHost.cs | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index e9a8cc7527..57d87749c3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -4,6 +4,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; +using MediaBrowser.Controller.Session; using System; using System.Collections.Generic; using System.Linq; @@ -14,10 +15,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security { private readonly IServerConfigurationManager _config; - public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager) + public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager, ISessionManager sessionManager) { AuthorizationContext = authorizationContext; _config = config; + SessionManager = sessionManager; ConnectManager = connectManager; UserManager = userManager; } @@ -25,6 +27,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security public IUserManager UserManager { get; private set; } public IAuthorizationContext AuthorizationContext { get; private set; } public IConnectManager ConnectManager { get; private set; } + public ISessionManager SessionManager { get; private set; } /// /// Redirect the client to a specific URL if authentication failed. @@ -91,6 +94,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security ValidateRoles(roles, user); } + + if (!string.IsNullOrWhiteSpace(auth.DeviceId) && + !string.IsNullOrWhiteSpace(auth.Client) && + !string.IsNullOrWhiteSpace(auth.Device)) + { + SessionManager.LogSessionActivity(auth.Client, + auth.Version, + auth.DeviceId, + auth.Device, + request.RemoteIp, + user); + } } private bool IsExemptFromAuthenticationToken(AuthorizationInfo auth, IAuthenticationAttributes authAttribtues) diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs index 2e38285128..b725af6107 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs @@ -140,5 +140,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp get { return response.SendChunked; } set { response.SendChunked = value; } } + + public bool KeepAlive { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 644b041f95..5682af386f 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -68,6 +68,7 @@ + @@ -408,10 +409,6 @@ - - swagger-ui\css\highlight.default.css - PreserveNewest - swagger-ui\css\screen.css PreserveNewest diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 4389dd98c5..1cfdfa3abf 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -499,7 +499,7 @@ namespace MediaBrowser.Server.Startup.Common var authContext = new AuthorizationContext(AuthenticationRepository); RegisterSingleInstance(authContext); RegisterSingleInstance(new SessionContext(UserManager, authContext, SessionManager)); - RegisterSingleInstance(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager)); + RegisterSingleInstance(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager)); RegisterSingleInstance(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer));