Merge pull request #3423 from crobibero/easypassword

Remove EasyPassword from Authentication providers
This commit is contained in:
Joshua M. Boniface 2020-07-04 00:25:00 -04:00 committed by GitHub
commit 46f67c9ea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 40 deletions

View File

@ -5,7 +5,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using MediaBrowser.Common;
using MediaBrowser.Common.Cryptography; using MediaBrowser.Common.Cryptography;
using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Authentication;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
@ -117,29 +116,5 @@ namespace Jellyfin.Server.Implementations.Users
return Task.CompletedTask; return Task.CompletedTask;
} }
/// <inheritdoc />
public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash)
{
if (newPassword != null)
{
newPasswordHash = _cryptographyProvider.CreatePasswordHash(newPassword).ToString();
}
if (string.IsNullOrWhiteSpace(newPasswordHash))
{
throw new ArgumentNullException(nameof(newPasswordHash));
}
user.EasyPassword = newPasswordHash;
}
/// <inheritdoc />
public string? GetEasyPasswordHash(User user)
{
return string.IsNullOrEmpty(user.EasyPassword)
? null
: Hex.Encode(PasswordHash.Parse(user.EasyPassword).Hash);
}
} }
} }

View File

@ -34,17 +34,5 @@ namespace Jellyfin.Server.Implementations.Users
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
/// <inheritdoc />
public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash)
{
// Nothing here
}
/// <inheritdoc />
public string GetEasyPasswordHash(User user)
{
return string.Empty;
}
} }
} }

View File

@ -273,7 +273,17 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/> /// <inheritdoc/>
public void ChangeEasyPassword(User user, string newPassword, string? newPasswordSha1) public void ChangeEasyPassword(User user, string newPassword, string? newPasswordSha1)
{ {
GetAuthenticationProvider(user).ChangeEasyPassword(user, newPassword, newPasswordSha1); if (newPassword != null)
{
newPasswordSha1 = _cryptoProvider.CreatePasswordHash(newPassword).ToString();
}
if (string.IsNullOrWhiteSpace(newPasswordSha1))
{
throw new ArgumentNullException(nameof(newPasswordSha1));
}
user.EasyPassword = newPasswordSha1;
UpdateUser(user); UpdateUser(user);
OnUserPasswordChanged?.Invoke(this, new GenericEventArgs<User>(user)); OnUserPasswordChanged?.Invoke(this, new GenericEventArgs<User>(user));

View File

@ -13,8 +13,6 @@ namespace MediaBrowser.Controller.Authentication
Task<ProviderAuthenticationResult> Authenticate(string username, string password); Task<ProviderAuthenticationResult> Authenticate(string username, string password);
bool HasPassword(User user); bool HasPassword(User user);
Task ChangePassword(User user, string newPassword); Task ChangePassword(User user, string newPassword);
void ChangeEasyPassword(User user, string newPassword, string newPasswordHash);
string GetEasyPasswordHash(User user);
} }
public interface IRequiresResolvedUser public interface IRequiresResolvedUser