mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 09:34:44 +01:00
minor changes and return to netstandard
This commit is contained in:
@@ -73,8 +73,9 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
}
|
||||
|
||||
private byte[] PBKDF2(string method, byte[] bytes, byte[] salt, int iterations)
|
||||
{
|
||||
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations, new HashAlgorithmName(method)))
|
||||
{
|
||||
//downgrading for now as we need this library to be dotnetstandard compliant
|
||||
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations))
|
||||
{
|
||||
return r.GetBytes(32);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ namespace Emby.Server.Implementations.Data
|
||||
if (!localUsersTableExists && TableExists(connection, "Users"))
|
||||
{
|
||||
TryMigrateToLocalUsersTable(connection);
|
||||
}
|
||||
}
|
||||
|
||||
RemoveEmptyPasswordHashes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Emby.Server.Implementations.Library
|
||||
string CalculatedHashString;
|
||||
if (_cryptographyProvider.GetSupportedHashMethods().Contains(readyHash.Id))
|
||||
{
|
||||
if (String.IsNullOrEmpty(readyHash.Salt))
|
||||
if (string.IsNullOrEmpty(readyHash.Salt))
|
||||
{
|
||||
CalculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes);
|
||||
CalculatedHashString = BitConverter.ToString(CalculatedHash).Replace("-", string.Empty);
|
||||
@@ -65,7 +65,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
CalculatedHash = _cryptographyProvider.ComputeHash(readyHash.Id, passwordbytes, readyHash.SaltBytes);
|
||||
CalculatedHashString = BitConverter.ToString(CalculatedHash).Replace("-", string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
if (CalculatedHashString == readyHash.Hash)
|
||||
{
|
||||
success = true;
|
||||
@@ -95,18 +96,20 @@ namespace Emby.Server.Implementations.Library
|
||||
private void ConvertPasswordFormat(User user)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(user.Password))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.Password.Contains("$"))
|
||||
{
|
||||
if (!user.Password.Contains("$"))
|
||||
{
|
||||
string hash = user.Password;
|
||||
user.Password = String.Format("$SHA1${0}", hash);
|
||||
}
|
||||
|
||||
if (user.EasyPassword != null && !user.EasyPassword.Contains("$"))
|
||||
{
|
||||
string hash = user.EasyPassword;
|
||||
user.EasyPassword = string.Format("$SHA1${0}", hash);
|
||||
}
|
||||
string hash = user.Password;
|
||||
user.Password = String.Format("$SHA1${0}", hash);
|
||||
}
|
||||
|
||||
if (user.EasyPassword != null && !user.EasyPassword.Contains("$"))
|
||||
{
|
||||
string hash = user.EasyPassword;
|
||||
user.EasyPassword = string.Format("$SHA1${0}", hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +125,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
return string.IsNullOrEmpty(password);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -188,7 +192,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
ConvertPasswordFormat(user);
|
||||
passwordHash = new PasswordHash(user.Password);
|
||||
}
|
||||
}
|
||||
|
||||
if (passwordHash.SaltBytes != null)
|
||||
{
|
||||
//the password is modern format with PBKDF and we should take advantage of that
|
||||
|
||||
@@ -221,9 +221,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
//This is some regex that matches only on unicode "word" characters, as well as -, _ and @
|
||||
//In theory this will cut out most if not all 'control' characters which should help minimize any weirdness
|
||||
string UserNameRegex = "^[\\w-'._@]*$";
|
||||
// Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
|
||||
return Regex.IsMatch(username, UserNameRegex);
|
||||
return Regex.IsMatch(username, "^[\\w-'._@]*$");
|
||||
}
|
||||
|
||||
private static bool IsValidUsernameCharacter(char i)
|
||||
|
||||
Reference in New Issue
Block a user