diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-07-13 00:55:56 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-07-13 00:55:56 -0400 |
| commit | baf44b2718162c7f1d4f3061e438efbafc22201b (patch) | |
| tree | 168e28a37bb4af62c195c0777703c5eae4eab72b /MediaBrowser.Server.Implementations/Session/SessionManager.cs | |
| parent | 8b630e2d41697ce2ff8b93b7904d884fc96058f4 (diff) | |
3.0.5306.42925
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/SessionManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/SessionManager.cs | 37 |
1 files changed, 5 insertions, 32 deletions
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 /// <param name="deviceId">The device identifier.</param> /// <param name="deviceName">Name of the device.</param> /// <param name="remoteEndPoint">The remote end point.</param> + /// <param name="isLocal">if set to <c>true</c> [is local].</param> /// <returns>Task{SessionInfo}.</returns> /// <exception cref="System.UnauthorizedAccessException">Invalid user or password entered.</exception> - /// <exception cref="UnauthorizedAccessException"></exception> + /// <exception cref="UnauthorizedAccessException">Invalid user or password entered.</exception> public async Task<AuthenticationResult> 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); - } - /// <summary> /// Reports the capabilities. /// </summary> |
