From b959b7d44792d7624a50b577ae14c8c83666f6ca Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Jan 2016 22:02:14 -0500 Subject: [PATCH 1/5] add back api keys --- MediaBrowser.Api/Session/SessionsService.cs | 3 ++- .../Security/AuthenticationInfoQuery.cs | 6 ++++++ .../Security/AuthenticationRepository.cs | 12 ++++++++++++ .../MediaBrowser.WebDashboard.csproj | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 1160f685c..416c4fff9 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -355,7 +355,8 @@ namespace MediaBrowser.Api.Session { var result = _authRepo.Get(new AuthenticationInfoQuery { - IsActive = true + IsActive = true, + HasUser = false }); return ToOptimizedResult(result); diff --git a/MediaBrowser.Controller/Security/AuthenticationInfoQuery.cs b/MediaBrowser.Controller/Security/AuthenticationInfoQuery.cs index 3234b0350..273dfd43c 100644 --- a/MediaBrowser.Controller/Security/AuthenticationInfoQuery.cs +++ b/MediaBrowser.Controller/Security/AuthenticationInfoQuery.cs @@ -27,6 +27,12 @@ namespace MediaBrowser.Controller.Security /// null if [is active] contains no value, true if [is active]; otherwise, false. public bool? IsActive { get; set; } + /// + /// Gets or sets a value indicating whether this instance has user. + /// + /// null if [has user] contains no value, true if [has user]; otherwise, false. + public bool? HasUser { get; set; } + /// /// Gets or sets the start index. /// diff --git a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs index df7cc47f4..b36db51b3 100644 --- a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs +++ b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs @@ -185,6 +185,18 @@ namespace MediaBrowser.Server.Implementations.Security cmd.Parameters.Add(cmd, "@IsActive", DbType.Boolean).Value = query.IsActive.Value; } + if (query.HasUser.HasValue) + { + if (query.HasUser.Value) + { + whereClauses.Add("UserId not null"); + } + else + { + whereClauses.Add("UserId is null"); + } + } + var whereTextWithoutPaging = whereClauses.Count == 0 ? string.Empty : " where " + string.Join(" AND ", whereClauses.ToArray()); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 48a8bf253..2a2515197 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -293,6 +293,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -323,6 +326,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 1055c1c77e385ade8653972bac16ff3368ea4a09 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Jan 2016 22:02:26 -0500 Subject: [PATCH 2/5] normalize remote ip --- .../SocketSharp/WebSocketSharpRequest.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs index b3fbd2d1d..5df37118d 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs @@ -136,11 +136,27 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { return remoteIp ?? (remoteIp = XForwardedFor ?? - (XRealIp ?? - ((request.RemoteEndPoint != null) ? request.RemoteEndPoint.Address.ToString() : null))); + (NormalizeIp(XRealIp) ?? + ((request.RemoteEndPoint != null) ? NormalizeIp(request.RemoteEndPoint.Address.ToString()) : null))); } } + private string NormalizeIp(string ip) + { + if (!string.IsNullOrWhiteSpace(ip)) + { + // Handle ipv4 mapped to ipv6 + const string srch = "::ffff:"; + var index = ip.IndexOf(srch, StringComparison.OrdinalIgnoreCase); + if (index == 0) + { + ip = ip.Substring(srch.Length); + } + } + + return ip; + } + public bool IsSecureConnection { get { return request.IsSecureConnection || XForwardedProtocol == "https"; } From d9c678afaf5cdeaaa771ec6378e24661df55883b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Jan 2016 22:05:56 -0500 Subject: [PATCH 3/5] 3.0.5815 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 1f9e07f26..056572276 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; //[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5814")] +[assembly: AssemblyVersion("3.0.5815")] From 7f7d80bf64fb9847741ec24b222d9416636c22d1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Jan 2016 13:11:02 -0500 Subject: [PATCH 4/5] trim logging --- MediaBrowser.Api/ApiEntryPoint.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 818b40b20..55f191f1a 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -294,7 +294,7 @@ namespace MediaBrowser.Api public void OnTranscodeEndRequest(TranscodingJob job) { job.ActiveRequestCount--; - Logger.Debug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); + //Logger.Debug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); if (job.ActiveRequestCount <= 0) { PingTimer(job, false); @@ -307,7 +307,7 @@ namespace MediaBrowser.Api throw new ArgumentNullException("playSessionId"); } - Logger.Debug("PingTranscodingJob PlaySessionId={0}", playSessionId); + //Logger.Debug("PingTranscodingJob PlaySessionId={0}", playSessionId); var jobs = new List(); From 17680d59b6e2de318ab5e540e39f8c0c776114c0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Jan 2016 13:38:09 -0500 Subject: [PATCH 5/5] 3.0.5816 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 056572276..706b83996 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; //[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5815")] +[assembly: AssemblyVersion("3.0.5816")]