aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
diff options
context:
space:
mode:
authorPhallacy <Dragoonmac@gmail.com>2019-02-18 01:26:01 -0800
committerPhallacy <Dragoonmac@gmail.com>2019-02-18 01:26:01 -0800
commit48e7274d3783e57f89f6e1cc76fcd8696e987ec5 (patch)
tree8c4fe049728082d18f3f3ca8b4dd9c54c79a3e50 /Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
parent9f3aa2cead95ec0a66a518919c179eea4cad5d9c (diff)
added justaman notes, fixed new bug from emty has removals
Diffstat (limited to 'Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs')
-rw-r--r--Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs42
1 files changed, 31 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
index 016de6db7..80026d97c 100644
--- a/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
+++ b/Emby.Server.Implementations/Library/DefaultAuthenticationProvider.cs
@@ -37,7 +37,17 @@ namespace Emby.Server.Implementations.Library
if (resolvedUser == null)
{
throw new Exception("Invalid username or password");
- }
+ }
+
+ //As long as jellyfin supports passwordless users, we need this little block here to accomodate
+ if (IsPasswordEmpty(resolvedUser, password))
+ {
+ return Task.FromResult(new ProviderAuthenticationResult
+ {
+ Username = username
+ });
+ }
+
ConvertPasswordFormat(resolvedUser);
byte[] passwordbytes = Encoding.UTF8.GetBytes(password);
@@ -106,15 +116,30 @@ namespace Emby.Server.Implementations.Library
return Task.FromResult(hasConfiguredPassword);
}
- private bool IsPasswordEmpty(User user, string passwordHash)
- {
- return string.IsNullOrEmpty(passwordHash);
+ private bool IsPasswordEmpty(User user, string password)
+ {
+ if (string.IsNullOrEmpty(user.Password))
+ {
+ return string.IsNullOrEmpty(password);
+ }
+ return false;
}
public Task ChangePassword(User user, string newPassword)
{
- //string newPasswordHash = null;
- ConvertPasswordFormat(user);
+ ConvertPasswordFormat(user);
+ //This is needed to support changing a no password user to a password user
+ if (string.IsNullOrEmpty(user.Password))
+ {
+ PasswordHash newPasswordHash = new PasswordHash(_cryptographyProvider);
+ newPasswordHash.SaltBytes = _cryptographyProvider.GenerateSalt();
+ newPasswordHash.Salt = PasswordHash.ConvertToByteString(newPasswordHash.SaltBytes);
+ newPasswordHash.Id = _cryptographyProvider.DefaultHashMethod;
+ newPasswordHash.Hash = GetHashedStringChangeAuth(newPassword, newPasswordHash);
+ user.Password = newPasswordHash.ToString();
+ return Task.CompletedTask;
+ }
+
PasswordHash passwordHash = new PasswordHash(user.Password);
if (passwordHash.Id == "SHA1" && string.IsNullOrEmpty(passwordHash.Salt))
{
@@ -143,11 +168,6 @@ namespace Emby.Server.Implementations.Library
return user.Password;
}
- public string GetEmptyHashedString(User user)
- {
- return null;
- }
-
public string GetHashedStringChangeAuth(string newPassword, PasswordHash passwordHash)
{
passwordHash.HashBytes = Encoding.UTF8.GetBytes(newPassword);