mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #2034 from Bond-009/easypass
Fix easy password (cherry picked from commit 13dd63d631d63ad9e1818af88a3662cae7c88f52) Signed-off-by: Joshua Boniface <joshua@boniface.me>
This commit is contained in:
parent
ffd7835ab5
commit
0f18482ba6
@ -746,7 +746,8 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
serviceCollection.AddSingleton(typeof(IStreamHelper), typeof(StreamHelper));
|
serviceCollection.AddSingleton(typeof(IStreamHelper), typeof(StreamHelper));
|
||||||
|
|
||||||
serviceCollection.AddSingleton(typeof(ICryptoProvider), typeof(CryptographyProvider));
|
var cryptoProvider = new CryptographyProvider();
|
||||||
|
serviceCollection.AddSingleton<ICryptoProvider>(cryptoProvider);
|
||||||
|
|
||||||
SocketFactory = new SocketFactory();
|
SocketFactory = new SocketFactory();
|
||||||
serviceCollection.AddSingleton(SocketFactory);
|
serviceCollection.AddSingleton(SocketFactory);
|
||||||
@ -786,7 +787,17 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
_userRepository = GetUserRepository();
|
_userRepository = GetUserRepository();
|
||||||
|
|
||||||
UserManager = new UserManager(LoggerFactory.CreateLogger<UserManager>(), _userRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager);
|
UserManager = new UserManager(
|
||||||
|
LoggerFactory.CreateLogger<UserManager>(),
|
||||||
|
_userRepository,
|
||||||
|
XmlSerializer,
|
||||||
|
NetworkManager,
|
||||||
|
() => ImageProcessor,
|
||||||
|
() => DtoService,
|
||||||
|
this,
|
||||||
|
JsonSerializer,
|
||||||
|
FileSystemManager,
|
||||||
|
cryptoProvider);
|
||||||
|
|
||||||
serviceCollection.AddSingleton(UserManager);
|
serviceCollection.AddSingleton(UserManager);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ using MediaBrowser.Controller.Providers;
|
|||||||
using MediaBrowser.Controller.Security;
|
using MediaBrowser.Controller.Security;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Cryptography;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
@ -60,6 +61,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
private readonly Func<IDtoService> _dtoServiceFactory;
|
private readonly Func<IDtoService> _dtoServiceFactory;
|
||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly ICryptoProvider _cryptoProvider;
|
||||||
|
|
||||||
private ConcurrentDictionary<Guid, User> _users;
|
private ConcurrentDictionary<Guid, User> _users;
|
||||||
|
|
||||||
@ -80,7 +82,8 @@ namespace Emby.Server.Implementations.Library
|
|||||||
Func<IDtoService> dtoServiceFactory,
|
Func<IDtoService> dtoServiceFactory,
|
||||||
IServerApplicationHost appHost,
|
IServerApplicationHost appHost,
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IFileSystem fileSystem)
|
IFileSystem fileSystem,
|
||||||
|
ICryptoProvider cryptoProvider)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
@ -91,6 +94,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_cryptoProvider = cryptoProvider;
|
||||||
_users = null;
|
_users = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,24 +479,21 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
if (!success
|
if (!success
|
||||||
&& _networkManager.IsInLocalNetwork(remoteEndPoint)
|
&& _networkManager.IsInLocalNetwork(remoteEndPoint)
|
||||||
&& user.Configuration.EnableLocalPassword)
|
&& user.Configuration.EnableLocalPassword
|
||||||
|
&& !string.IsNullOrEmpty(user.EasyPassword))
|
||||||
{
|
{
|
||||||
success = string.Equals(
|
// Check easy password
|
||||||
GetLocalPasswordHash(user),
|
var passwordHash = PasswordHash.Parse(user.EasyPassword);
|
||||||
_defaultAuthenticationProvider.GetHashedString(user, password),
|
var hash = _cryptoProvider.ComputeHash(
|
||||||
StringComparison.OrdinalIgnoreCase);
|
passwordHash.Id,
|
||||||
|
Encoding.UTF8.GetBytes(password),
|
||||||
|
passwordHash.Salt);
|
||||||
|
success = passwordHash.Hash.SequenceEqual(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (authenticationProvider, username, success);
|
return (authenticationProvider, username, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetLocalPasswordHash(User user)
|
|
||||||
{
|
|
||||||
return string.IsNullOrEmpty(user.EasyPassword)
|
|
||||||
? null
|
|
||||||
: ToHexString(PasswordHash.Parse(user.EasyPassword).Hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ResetInvalidLoginAttemptCount(User user)
|
private void ResetInvalidLoginAttemptCount(User user)
|
||||||
{
|
{
|
||||||
user.Policy.InvalidLoginAttemptCount = 0;
|
user.Policy.InvalidLoginAttemptCount = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user