From baf44b2718162c7f1d4f3061e438efbafc22201b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 13 Jul 2014 00:55:56 -0400 Subject: 3.0.5306.42925 --- .../Session/SessionManager.cs | 37 +++------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Session') diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 1d1910e40..754f63cbd 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1207,18 +1207,20 @@ namespace MediaBrowser.Server.Implementations.Session /// The device identifier. /// Name of the device. /// The remote end point. + /// if set to true [is local]. /// Task{SessionInfo}. /// Invalid user or password entered. - /// + /// Invalid user or password entered. public async Task AuthenticateNewSession(string username, string password, string clientType, string appVersion, string deviceId, string deviceName, - string remoteEndPoint) + string remoteEndPoint, + bool isLocal) { - var result = (IsLocalhost(remoteEndPoint) && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) || + var result = (isLocal && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) || await _userManager.AuthenticateUser(username, password).ConfigureAwait(false); if (!result) @@ -1337,35 +1339,6 @@ namespace MediaBrowser.Server.Implementations.Session return Logout(token); } - private bool IsLocalhost(string remoteEndpoint) - { - if (string.IsNullOrWhiteSpace(remoteEndpoint)) - { - throw new ArgumentNullException("remoteEndpoint"); - } - - return remoteEndpoint.IndexOf("localhost", StringComparison.OrdinalIgnoreCase) != -1 || - remoteEndpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("::", StringComparison.OrdinalIgnoreCase); - } - - public bool IsInLocalNetwork(string remoteEndpoint) - { - if (string.IsNullOrWhiteSpace(remoteEndpoint)) - { - throw new ArgumentNullException("remoteEndpoint"); - } - - // Private address space: - // http://en.wikipedia.org/wiki/Private_network - - return IsLocalhost(remoteEndpoint) || - remoteEndpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("192.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("172.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase); - } - /// /// Reports the capabilities. /// -- cgit v1.2.3