mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-23 01:05:19 +03:00
3.0.5306.42925
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user