From e0161d62db3b5f6b29100015e39b63f26074c6f9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 01:24:39 -0400 Subject: [PATCH 1/7] update hw filters --- .../MediaEncoding/EncodingHelper.cs | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 1060dc8def..6b7b40853a 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1400,13 +1400,22 @@ namespace MediaBrowser.Controller.MediaEncoding } else { + var isExynosV4L2 = string.Equals(outputVideoCodec, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase); + // If fixed dimensions were supplied if (request.Width.HasValue && request.Height.HasValue) { var widthParam = request.Width.Value.ToString(_usCulture); var heightParam = request.Height.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc({0}/2)*2:trunc({1}/2)*2", widthParam, heightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc({0}/64)*64:trunc({1}/2)*2", widthParam, heightParam)); + } + else + { + filters.Add(string.Format("scale=trunc({0}/2)*2:trunc({1}/2)*2", widthParam, heightParam)); + } } // If Max dimensions were supplied, for width selects lowest even number between input width and width req size and selects lowest even number from in width*display aspect and requested size @@ -1415,7 +1424,14 @@ namespace MediaBrowser.Controller.MediaEncoding var maxWidthParam = request.MaxWidth.Value.ToString(_usCulture); var maxHeightParam = request.MaxHeight.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/64)*64:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + } } // If a fixed width was requested @@ -1431,7 +1447,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var heightParam = request.Height.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(oh*a/64)*64:{0}", heightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam)); + } } // If a max width was requested @@ -1439,7 +1462,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var maxWidthParam = request.MaxWidth.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2", maxWidthParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/64)*64:trunc(ow/dar/2)*2", maxWidthParam)); + } + else + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2", maxWidthParam)); + } } // If a max height was requested @@ -1447,7 +1477,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var maxHeightParam = request.MaxHeight.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(oh*a/64)*64:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + } } } @@ -1903,9 +1940,9 @@ namespace MediaBrowser.Controller.MediaEncoding { case "avc": case "h264": - if (_mediaEncoder.SupportsDecoder("h264_omx") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) + if (_mediaEncoder.SupportsDecoder("h264_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) { - return "-c:v h264_omx "; + return "-c:v h264_mmal"; } break; } From 48d1e2b85b8aba122b49c5b543526b5cfabb6ee3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 01:25:55 -0400 Subject: [PATCH 2/7] flush before socket transfer --- .../Net/HttpResponseStream.Managed.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 7e175f8d65..2de3fbb948 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -285,16 +285,11 @@ namespace SocketHttpListener.Net } } - private bool EnableSendFileWithSocket = false; - public Task TransmitFile(string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken) { - //if (_supportsDirectSocketAccess && offset == 0 && count == 0 && !_response.SendChunked && _response.ContentLength64 > 8192) + //if (_supportsDirectSocketAccess && offset == 0 && count == 0 && !_response.SendChunked) //{ - // if (EnableSendFileWithSocket) - // { - // return TransmitFileOverSocket(path, offset, count, fileShareMode, cancellationToken); - // } + // return TransmitFileOverSocket(path, offset, count, fileShareMode, cancellationToken); //} return TransmitFileManaged(path, offset, count, fileShareMode, cancellationToken); @@ -319,7 +314,9 @@ namespace SocketHttpListener.Net return TransmitFileManaged(path, offset, count, fileShareMode, cancellationToken); } - //_logger.Info("Socket sending file {0} {1}", path, response.ContentLength64); + _stream.Flush(); + + _logger.Info("Socket sending file {0}", path); var taskCompletion = new TaskCompletionSource(); From c7656fb604a52583ff188b634cf554b140d961ba Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 01:27:15 -0400 Subject: [PATCH 3/7] removed dead code --- MediaBrowser.Model/Dto/UserDto.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/MediaBrowser.Model/Dto/UserDto.cs b/MediaBrowser.Model/Dto/UserDto.cs index 99f69e2030..2b5672896c 100644 --- a/MediaBrowser.Model/Dto/UserDto.cs +++ b/MediaBrowser.Model/Dto/UserDto.cs @@ -54,18 +54,6 @@ namespace MediaBrowser.Model.Dto /// The id. public string Id { get; set; } - /// - /// Gets or sets the offline password. - /// - /// The offline password. - public string OfflinePassword { get; set; } - - /// - /// Gets or sets the offline password salt. - /// - /// The offline password salt. - public string OfflinePasswordSalt { get; set; } - /// /// Gets or sets the primary image tag. /// From 3a1efe9edc92c1bbe7f280e636339bc0aceb0629 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 01:30:11 -0400 Subject: [PATCH 4/7] add xbox one workaround --- Emby.Dlna/PlayTo/PlayToManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index 6f2f5f24b3..dd30dfc3d9 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -194,7 +194,10 @@ namespace Emby.Dlna.PlayTo GeneralCommandType.SetSubtitleStreamIndex.ToString() }, - SupportsMediaControl = true + SupportsMediaControl = true, + + // xbox one creates a new uuid everytime it restarts + SupportsPersistentIdentifier = (device.Properties.ModelName ?? string.Empty).IndexOf("xbox", StringComparison.OrdinalIgnoreCase) == -1 }); _logger.Info("DLNA Session created for {0} - {1}", device.Properties.Name, device.Properties.ModelName); From 1f12ab66580a8cda5a4a5e1f44f469baeed07f16 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 02:42:23 -0400 Subject: [PATCH 5/7] add yadif setting --- .../LiveTv/EmbyTV/EncodedRecorder.cs | 11 ++++++-- .../MediaEncoding/EncodingHelper.cs | 25 ++++++++++--------- .../Configuration/EncodingOptions.cs | 1 + 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 48eba4117b..149f69e5b3 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -284,8 +284,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV protected string GetOutputSizeParam() { var filters = new List(); - - filters.Add("yadif=0:-1:0"); + + if (string.Equals(GetEncodingOptions().DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase)) + { + filters.Add("yadif=1:-1:0"); + } + else + { + filters.Add("yadif=0:-1:0"); + } var output = string.Empty; diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 6b7b40853a..a10a0bec85 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1288,10 +1288,7 @@ namespace MediaBrowser.Controller.MediaEncoding /// /// Gets the internal graphical subtitle param. /// - /// The state. - /// The output video codec. - /// System.String. - public string GetGraphicalSubtitleParam(EncodingJobInfo state, string outputVideoCodec) + public string GetGraphicalSubtitleParam(EncodingJobInfo state, EncodingOptions options, string outputVideoCodec) { var outputSizeParam = string.Empty; @@ -1300,7 +1297,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Add resolution params, if specified if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue) { - outputSizeParam = GetOutputSizeParam(state, outputVideoCodec).TrimEnd('"'); + outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"'); if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { @@ -1343,11 +1340,8 @@ namespace MediaBrowser.Controller.MediaEncoding /// /// If we're going to put a fixed size on the command line, this will calculate it /// - /// The state. - /// The output video codec. - /// if set to true [allow time stamp copy]. - /// System.String. public string GetOutputSizeParam(EncodingJobInfo state, + EncodingOptions options, string outputVideoCodec, bool allowTimeStampCopy = true) { @@ -1365,7 +1359,14 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.DeInterlace && !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { - filters.Add("yadif=0:-1:0"); + if (string.Equals(options.DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase)) + { + filters.Add("yadif=1:-1:0"); + } + else + { + filters.Add("yadif=0:-1:0"); + } } if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) @@ -2092,7 +2093,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Add resolution params, if specified if (!hasGraphicalSubs) { - var outputSizeParam = GetOutputSizeParam(state, videoCodec); + var outputSizeParam = GetOutputSizeParam(state, encodingOptions, videoCodec); args += outputSizeParam; hasCopyTs = outputSizeParam.IndexOf("copyts", StringComparison.OrdinalIgnoreCase) != -1; } @@ -2116,7 +2117,7 @@ namespace MediaBrowser.Controller.MediaEncoding // This is for internal graphical subs if (hasGraphicalSubs) { - args += GetGraphicalSubtitleParam(state, videoCodec); + args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec); } if (!state.RunTimeTicks.HasValue) diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs index b093d82e33..a143bb9e3c 100644 --- a/MediaBrowser.Model/Configuration/EncodingOptions.cs +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -13,6 +13,7 @@ namespace MediaBrowser.Model.Configuration public string VaapiDevice { get; set; } public int H264Crf { get; set; } public string H264Preset { get; set; } + public string DeinterlaceMethod { get; set; } public bool EnableHardwareEncoding { get; set; } public bool EnableSubtitleExtraction { get; set; } From bca1d65bdc026578e270b19b6129b79faeb53969 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 12:45:23 -0400 Subject: [PATCH 6/7] fixes #1074 --- .../Library/UserManager.cs | 128 ++++++++++++------ MediaBrowser.Api/UserService.cs | 24 +++- .../Connect/IConnectManager.cs | 5 +- MediaBrowser.Controller/Entities/User.cs | 1 + .../Library/IUserManager.cs | 27 +--- .../Session/AuthenticationRequest.cs | 1 + 6 files changed, 108 insertions(+), 78 deletions(-) diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index e3c36fc021..c9de3c01b1 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -180,11 +180,6 @@ namespace Emby.Server.Implementations.Library } } - public Task AuthenticateUser(string username, string passwordSha1, string remoteEndPoint) - { - return AuthenticateUser(username, passwordSha1, null, remoteEndPoint); - } - public bool IsValidUsername(string username) { // Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.) @@ -223,7 +218,7 @@ namespace Emby.Server.Implementations.Library return builder.ToString(); } - public async Task AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint) + public async Task AuthenticateUser(string username, string password, string hashedPassword, string passwordMd5, string remoteEndPoint) { if (string.IsNullOrWhiteSpace(username)) { @@ -237,23 +232,23 @@ namespace Emby.Server.Implementations.Library if (user != null) { + if (password != null) + { + hashedPassword = GetHashedString(user, password); + } + // Authenticate using local credentials if not a guest if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value != UserLinkType.Guest) { - success = string.Equals(GetPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); - - if (!success && _networkManager.IsInLocalNetwork(remoteEndPoint) && user.Configuration.EnableLocalPassword) - { - success = string.Equals(GetLocalPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); - } + success = AuthenticateLocalUser(user, password, hashedPassword, remoteEndPoint); } // Maybe user accidently entered connect credentials. let's be flexible - if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(passwordMd5) && !string.IsNullOrWhiteSpace(user.ConnectUserName)) + if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(user.ConnectUserName)) { try { - await _connectFactory().Authenticate(user.ConnectUserName, passwordMd5).ConfigureAwait(false); + await _connectFactory().Authenticate(user.ConnectUserName, password, passwordMd5).ConfigureAwait(false); success = true; } catch @@ -268,7 +263,7 @@ namespace Emby.Server.Implementations.Library { try { - var connectAuthResult = await _connectFactory().Authenticate(username, passwordMd5).ConfigureAwait(false); + var connectAuthResult = await _connectFactory().Authenticate(username, password, passwordMd5).ConfigureAwait(false); user = Users.FirstOrDefault(i => string.Equals(i.ConnectUserId, connectAuthResult.User.Id, StringComparison.OrdinalIgnoreCase)); @@ -307,6 +302,36 @@ namespace Emby.Server.Implementations.Library return success ? user : null; } + private bool AuthenticateLocalUser(User user, string password, string hashedPassword, string remoteEndPoint) + { + bool success; + + if (password == null) + { + // legacy + success = string.Equals(GetPasswordHash(user), hashedPassword.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); + } + else + { + success = string.Equals(GetPasswordHash(user), GetHashedString(user, password), StringComparison.OrdinalIgnoreCase); + } + + if (!success && _networkManager.IsInLocalNetwork(remoteEndPoint) && user.Configuration.EnableLocalPassword) + { + if (password == null) + { + // legacy + success = string.Equals(GetLocalPasswordHash(user), hashedPassword.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); + } + else + { + success = string.Equals(GetLocalPasswordHash(user), GetHashedString(user, password), StringComparison.OrdinalIgnoreCase); + } + } + + return success; + } + private void UpdateInvalidLoginAttemptCount(User user, int newValue) { if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0) @@ -342,29 +367,39 @@ namespace Emby.Server.Implementations.Library private string GetPasswordHash(User user) { return string.IsNullOrEmpty(user.Password) - ? GetSha1String(string.Empty) + ? GetEmptyHashedString(user) : user.Password; } private string GetLocalPasswordHash(User user) { return string.IsNullOrEmpty(user.EasyPassword) - ? GetSha1String(string.Empty) + ? GetEmptyHashedString(user) : user.EasyPassword; } - private bool IsPasswordEmpty(string passwordHash) + private bool IsPasswordEmpty(User user, string passwordHash) { - return string.Equals(passwordHash, GetSha1String(string.Empty), StringComparison.OrdinalIgnoreCase); + return string.Equals(passwordHash, GetEmptyHashedString(user), StringComparison.OrdinalIgnoreCase); + } + + private string GetEmptyHashedString(User user) + { + return GetHashedString(user, string.Empty); } /// - /// Gets the sha1 string. + /// Gets the hashed string. /// - /// The STR. - /// System.String. - private string GetSha1String(string str) + private string GetHashedString(User user, string str) { + var salt = user.Salt; + if (salt != null) + { + // return BCrypt.HashPassword(str, salt); + } + + // legacy return BitConverter.ToString(_cryptographyProvider.ComputeSHA1(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty); } @@ -407,8 +442,8 @@ namespace Emby.Server.Implementations.Library var passwordHash = GetPasswordHash(user); - var hasConfiguredPassword = !IsPasswordEmpty(passwordHash); - var hasConfiguredEasyPassword = !IsPasswordEmpty(GetLocalPasswordHash(user)); + var hasConfiguredPassword = !IsPasswordEmpty(user, passwordHash); + var hasConfiguredEasyPassword = !IsPasswordEmpty(user, GetLocalPasswordHash(user)); var hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ? hasConfiguredEasyPassword : @@ -460,14 +495,6 @@ namespace Emby.Server.Implementations.Library { var dto = GetUserDto(user); - var offlinePasswordHash = GetLocalPasswordHash(user); - dto.HasPassword = !IsPasswordEmpty(offlinePasswordHash); - - dto.OfflinePasswordSalt = Guid.NewGuid().ToString("N"); - - // Hash the pin with the device Id to create a unique result for this device - dto.OfflinePassword = GetSha1String((offlinePasswordHash + dto.OfflinePasswordSalt).ToLower()); - dto.ServerName = _appHost.FriendlyName; return dto; @@ -682,23 +709,29 @@ namespace Emby.Server.Implementations.Library /// Task. public void ResetPassword(User user) { - ChangePassword(user, GetSha1String(string.Empty)); + ChangePassword(user, string.Empty, null); } public void ResetEasyPassword(User user) { - ChangeEasyPassword(user, GetSha1String(string.Empty)); + ChangeEasyPassword(user, string.Empty, null); } - public void ChangePassword(User user, string newPasswordSha1) + public void ChangePassword(User user, string newPassword, string newPasswordHash) { if (user == null) { throw new ArgumentNullException("user"); } - if (string.IsNullOrWhiteSpace(newPasswordSha1)) + + if (newPassword != null) + { + newPasswordHash = GetHashedString(user, newPassword); + } + + if (string.IsNullOrWhiteSpace(newPasswordHash)) { - throw new ArgumentNullException("newPasswordSha1"); + throw new ArgumentNullException("newPasswordHash"); } if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest) @@ -706,25 +739,31 @@ namespace Emby.Server.Implementations.Library throw new ArgumentException("Passwords for guests cannot be changed."); } - user.Password = newPasswordSha1; + user.Password = newPasswordHash; UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } - public void ChangeEasyPassword(User user, string newPasswordSha1) + public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash) { if (user == null) { throw new ArgumentNullException("user"); } - if (string.IsNullOrWhiteSpace(newPasswordSha1)) + + if (newPassword != null) + { + newPasswordHash = GetHashedString(user, newPassword); + } + + if (string.IsNullOrWhiteSpace(newPasswordHash)) { - throw new ArgumentNullException("newPasswordSha1"); + throw new ArgumentNullException("newPasswordHash"); } - user.EasyPassword = newPasswordSha1; + user.EasyPassword = newPasswordHash; UpdateUser(user); @@ -744,7 +783,8 @@ namespace Emby.Server.Implementations.Library Id = Guid.NewGuid(), DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, - UsesIdForConfigurationPath = true + UsesIdForConfigurationPath = true, + //Salt = BCrypt.GenerateSalt() }; } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 512356b43a..ddefb08dff 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -97,6 +97,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] public string Id { get; set; } + [ApiMember(Name = "Pw", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] + public string Pw { get; set; } + /// /// Gets or sets the password. /// @@ -125,6 +128,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "Password", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] public string Password { get; set; } + [ApiMember(Name = "Pw", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] + public string Pw { get; set; } + [ApiMember(Name = "PasswordMd5", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] public string PasswordMd5 { get; set; } } @@ -148,12 +154,16 @@ namespace MediaBrowser.Api /// The password. public string CurrentPassword { get; set; } + public string CurrentPw { get; set; } + /// /// Gets or sets the new password. /// /// The new password. public string NewPassword { get; set; } + public string NewPw { get; set; } + /// /// Gets or sets a value indicating whether [reset password]. /// @@ -180,6 +190,8 @@ namespace MediaBrowser.Api /// The new password. public string NewPassword { get; set; } + public string NewPw { get; set; } + /// /// Gets or sets a value indicating whether [reset password]. /// @@ -408,7 +420,8 @@ namespace MediaBrowser.Api return Post(new AuthenticateUserByName { Username = user.Name, - Password = request.Password + Password = request.Password, + Pw = request.Pw }); } @@ -422,6 +435,7 @@ namespace MediaBrowser.Api AppVersion = auth.Version, DeviceId = auth.DeviceId, DeviceName = auth.Device, + Password = request.Pw, PasswordSha1 = request.Password, PasswordMd5 = request.PasswordMd5, RemoteEndPoint = Request.RemoteIp, @@ -459,14 +473,14 @@ namespace MediaBrowser.Api } else { - var success = await _userManager.AuthenticateUser(user.Name, request.CurrentPassword, Request.RemoteIp).ConfigureAwait(false); + var success = await _userManager.AuthenticateUser(user.Name, request.CurrentPw, request.CurrentPassword, null, Request.RemoteIp).ConfigureAwait(false); if (success == null) { throw new ArgumentException("Invalid user or password entered."); } - _userManager.ChangePassword(user, request.NewPassword); + _userManager.ChangePassword(user, request.NewPw, request.NewPassword); var currentToken = _authContext.GetAuthorizationInfo(Request).Token; @@ -491,7 +505,7 @@ namespace MediaBrowser.Api } else { - _userManager.ChangeEasyPassword(user, request.NewPassword); + _userManager.ChangeEasyPassword(user, request.NewPw, request.NewPassword); } } @@ -501,8 +515,6 @@ namespace MediaBrowser.Api /// The request. public void Post(UpdateUser request) { - // We need to parse this manually because we told service stack not to with IRequiresRequestStream - // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs var id = GetPathValue(1); AssertCanUpdateUser(_authContext, _userManager, id, false); diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index f899c72623..70bdc52e63 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -58,10 +58,7 @@ namespace MediaBrowser.Controller.Connect /// /// Authenticates the specified username. /// - /// The username. - /// The password MD5. - /// Task. - Task Authenticate(string username, string passwordMd5); + Task Authenticate(string username, string password, string passwordMd5); /// /// Gets the local user. diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 3c89037cca..cca3091c15 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -30,6 +30,7 @@ namespace MediaBrowser.Controller.Entities /// The password. public string Password { get; set; } public string EasyPassword { get; set; } + public string Salt { get; set; } public string ConnectUserName { get; set; } public string ConnectUserId { get; set; } diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index 6da3e53aab..d4232c77e0 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -58,16 +58,6 @@ namespace MediaBrowser.Controller.Library /// User. User GetUserByName(string name); - /// - /// Authenticates a User and returns a result indicating whether or not it succeeded - /// - /// The username. - /// The password sha1. - /// The remote end point. - /// Task{System.Boolean}. - /// user - Task AuthenticateUser(string username, string passwordSha1, string remoteEndPoint); - /// /// Refreshes metadata for each user /// @@ -135,18 +125,12 @@ namespace MediaBrowser.Controller.Library /// /// Changes the password. /// - /// The user. - /// The new password sha1. - /// Task. - void ChangePassword(User user, string newPasswordSha1); + void ChangePassword(User user, string newPassword, string newPasswordSha1); /// /// Changes the easy password. /// - /// The user. - /// The new password sha1. - /// Task. - void ChangeEasyPassword(User user, string newPasswordSha1); + void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1); /// /// Gets the user dto. @@ -159,12 +143,7 @@ namespace MediaBrowser.Controller.Library /// /// Authenticates the user. /// - /// The username. - /// The password sha1. - /// The password MD5. - /// The remote end point. - /// Task<System.Boolean>. - Task AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint); + Task AuthenticateUser(string username, string password, string passwordSha1, string passwordMd5, string remoteEndPoint); /// /// Starts the forgot password process. diff --git a/MediaBrowser.Controller/Session/AuthenticationRequest.cs b/MediaBrowser.Controller/Session/AuthenticationRequest.cs index 362f5b2b95..1b684fa8f2 100644 --- a/MediaBrowser.Controller/Session/AuthenticationRequest.cs +++ b/MediaBrowser.Controller/Session/AuthenticationRequest.cs @@ -5,6 +5,7 @@ namespace MediaBrowser.Controller.Session { public string Username { get; set; } public string UserId { get; set; } + public string Password { get; set; } public string PasswordSha1 { get; set; } public string PasswordMd5 { get; set; } public string App { get; set; } From 7c65dfa68214cfe40bb9104c7ba8b2c2dd8f59d8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 13:03:52 -0400 Subject: [PATCH 7/7] 3.2.30.24 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index efe35530d5..0b634e4fc7 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.30.23")] +[assembly: AssemblyVersion("3.2.30.24")]