Addressed the unsecure login HTTP endpoint and user the Performers property instead of the deprecated Artists property from the TagLib library. #38
This commit is contained in:
@@ -51,7 +51,7 @@ namespace Icarus.Controllers.Utilities
|
||||
{
|
||||
TagLib.File fileTag = TagLib.File.Create(filePath);
|
||||
_title = fileTag.Tag.Title;
|
||||
_artist = string.Join("", fileTag.Tag.Artists);
|
||||
_artist = string.Join("", fileTag.Tag.Performers);
|
||||
_album = fileTag.Tag.Album;
|
||||
_genre = string.Join("", fileTag.Tag.Genres);
|
||||
_year = (int)fileTag.Tag.Year;
|
||||
@@ -141,7 +141,7 @@ namespace Icarus.Controllers.Utilities
|
||||
break;
|
||||
case "artists":
|
||||
_updatedSong.Artist = artist;
|
||||
fileTag.Tag.Artists = new []{artist};
|
||||
fileTag.Tag.Performers = new []{artist};
|
||||
break;
|
||||
case "album":
|
||||
_updatedSong.AlbumTitle = album;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Security.Cryptography;
|
||||
|
||||
using BCrypt.Net;
|
||||
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
||||
using NLog;
|
||||
|
||||
using Icarus.Models;
|
||||
|
||||
@@ -11,6 +12,7 @@ namespace Icarus.Controllers.Utilities
|
||||
public class PasswordEncryption
|
||||
{
|
||||
#region Fields
|
||||
private static Logger _logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -23,6 +25,23 @@ namespace Icarus.Controllers.Utilities
|
||||
|
||||
|
||||
#region Methods
|
||||
public bool VerifyPassword(User user, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = BCrypt.Net.BCrypt.Verify(password, user.Password);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = ex.Message;
|
||||
_logger.Error(msg, "An error occurred");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string HashPassword(User user)
|
||||
{
|
||||
try
|
||||
@@ -30,12 +49,15 @@ namespace Icarus.Controllers.Utilities
|
||||
string hashedPassword = string.Empty;
|
||||
hashedPassword = BCrypt.Net.BCrypt.HashPassword(user.Password);
|
||||
|
||||
_logger.Info("Successfully hashed password");
|
||||
|
||||
return hashedPassword;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var exMsg = ex.Message;
|
||||
_logger.Error(exMsg, "An error occurred");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -45,11 +67,11 @@ namespace Icarus.Controllers.Utilities
|
||||
{
|
||||
|
||||
string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
||||
password: password,
|
||||
salt: salt,
|
||||
prf: KeyDerivationPrf.HMACSHA1,
|
||||
iterationCount: 10000,
|
||||
numBytesRequested: 256/8));
|
||||
password: password,
|
||||
salt: salt,
|
||||
prf: KeyDerivationPrf.HMACSHA1,
|
||||
iterationCount: 10000,
|
||||
numBytesRequested: 256/8));
|
||||
|
||||
return hashed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user