[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better default authentication #870

Merged
merged 22 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
49d9649
added submodule dir to gitignore
LogicalPhallacy Jan 31, 2019
4519ce2
Upgrade crypto provider, retarget better framework
LogicalPhallacy Jan 31, 2019
8bf88f4
Merge pull request #9 from jellyfin/master
LogicalPhallacy Feb 12, 2019
05bbf71
sha256 with salt auth and sha1 interop
LogicalPhallacy Feb 12, 2019
1dc5a62
fixed gitignore fail
LogicalPhallacy Feb 13, 2019
1ffd443
fixed nul user check to be first per justaman
LogicalPhallacy Feb 13, 2019
77602af
Minor fixes re:PR870, added null checks from PR876
LogicalPhallacy Feb 13, 2019
9e58e31
Update Emby.Server.Implementations/Library/DefaultAuthenticationProvi…
cvium Feb 13, 2019
d8e6808
Update Emby.Server.Implementations/Library/DefaultAuthenticationProvi…
cvium Feb 13, 2019
9f3aa2c
Apply suggestions from code review
LogicalPhallacy Feb 18, 2019
48e7274
added justaman notes, fixed new bug from emty has removals
LogicalPhallacy Feb 18, 2019
56e3063
little fixes for JustAMan
LogicalPhallacy Feb 18, 2019
6bbb968
minor changes and return to netstandard
LogicalPhallacy Feb 20, 2019
a0d31a4
merging with master to clear merge conflict
LogicalPhallacy Feb 20, 2019
098de6b
made newlines into linux newlines
LogicalPhallacy Feb 20, 2019
edba82d
fixed logic flip in auth empty check and fixed crypto algo choice
LogicalPhallacy Feb 28, 2019
2c26517
minor style fixes
LogicalPhallacy Mar 5, 2019
bef665b
Minor fixes to address style issues
LogicalPhallacy Mar 6, 2019
c31b0b3
Apply suggestions from code review
Bond-009 Mar 7, 2019
8f4895e
more fixes for perf and style
LogicalPhallacy Mar 7, 2019
dfb1d70
made hashset static and readonly
LogicalPhallacy Mar 7, 2019
f486f59
Update Emby.Server.Implementations/Library/DefaultAuthenticationProvi…
Bond-009 Mar 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more fixes for perf and style
  • Loading branch information
LogicalPhallacy committed Mar 7, 2019
commit 8f4895e8a5bd1549f41bc1d4d2b31d03cff689ad
35 changes: 19 additions & 16 deletions Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CryptographyProvider : ICryptoProvider

private RandomNumberGenerator _randomNumberGenerator;

private int _defaultIterations = 1000;
private const int _defaultIterations = 1000;

public CryptographyProvider()
{
Expand All @@ -27,20 +27,20 @@ public CryptographyProvider()
//Please note the default method of PBKDF2 is not included, it cannot be used to generate hashes cleanly as it is actually a pbkdf with sha1
_supportedHashMethods = new HashSet<string>()
{
"MD5"
,"System.Security.Cryptography.MD5"
,"SHA"
,"SHA1"
,"System.Security.Cryptography.SHA1"
,"SHA256"
,"SHA-256"
,"System.Security.Cryptography.SHA256"
,"SHA384"
,"SHA-384"
,"System.Security.Cryptography.SHA384"
,"SHA512"
,"SHA-512"
,"System.Security.Cryptography.SHA512"
"MD5",
"System.Security.Cryptography.MD5",
"SHA",
"SHA1",
"System.Security.Cryptography.SHA1",
"SHA256",
"SHA-256",
"System.Security.Cryptography.SHA256",
"SHA384",
"SHA-384",
"System.Security.Cryptography.SHA384",
"SHA512",
"SHA-512",
"System.Security.Cryptography.SHA512"
};
_randomNumberGenerator = RandomNumberGenerator.Create();
}
Expand Down Expand Up @@ -120,7 +120,10 @@ public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt)
}
else
{
return h.ComputeHash(bytes.Concat(salt).ToArray());
byte[] salted = new byte[bytes.Length + salt.Length];
Array.Copy(bytes, salted, bytes.Length);
Array.Copy(salt, 0, salted, bytes.Length, salt.Length);
return h.ComputeHash(salted);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions MediaBrowser.Model/Cryptography/PasswordHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ public PasswordHash(ICryptoProvider cryptoProvider)

public static byte[] ConvertFromByteString(string byteString)
{
List<byte> bytes = new List<byte>();
byte[] bytes = new byte[byteString.Length / 2];
for (int i = 0; i < byteString.Length; i += 2)
{
// TODO: NetStandard2.1 switch this to use a span instead of a substring.
bytes.Add(Convert.ToByte(byteString.Substring(i, 2), 16));
bytes[i / 2] = Convert.ToByte(byteString.Substring(i, 2), 16);
}

return bytes.ToArray();
return bytes;
}

public static string ConvertToByteString(byte[] bytes)
Expand All @@ -117,18 +117,18 @@ public static string ConvertToByteString(byte[] bytes)

private string SerializeParameters()
{
string ReturnString = string.Empty;
string returnString = string.Empty;
foreach (var KVP in _parameters)
{
ReturnString += $",{KVP.Key}={KVP.Value}";
returnString += $",{KVP.Key}={KVP.Value}";
}

if ((!string.IsNullOrEmpty(ReturnString)) && ReturnString[0] == ',')
if ((!string.IsNullOrEmpty(returnString)) && returnString[0] == ',')
{
ReturnString = ReturnString.Remove(0, 1);
returnString = returnString.Remove(0, 1);
}
LogicalPhallacy marked this conversation as resolved.
Show resolved Hide resolved

return ReturnString;
return returnString;
}

public override string ToString()
Expand Down