-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate file upload request. (#3655)
* validate file upload request. Fix #3654. * including the portal id and user id parameter.
- Loading branch information
Showing
6 changed files
with
101 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DotNetNuke.Entities.Host; | ||
using DotNetNuke.Security; | ||
|
||
namespace DotNetNuke.Common.Utilities | ||
{ | ||
public sealed class ValidationUtils | ||
{ | ||
internal static string GetDecryptionKey() | ||
{ | ||
var machineKey = Config.GetDecryptionkey(); | ||
var key = $"{machineKey ?? ""}{Host.GUID.Replace("-", string.Empty)}"; | ||
return FIPSCompliant.EncryptAES(key, key, Host.GUID); | ||
} | ||
|
||
internal static string ComputeValidationCode(IList<object> parameters) | ||
{ | ||
if (parameters != null && parameters.Any()) | ||
{ | ||
var checkString = string.Join("_", parameters.Select(p => | ||
{ | ||
if (p is IList<string> list) | ||
{ | ||
return list.Select(i => i.ToLowerInvariant()) | ||
.OrderBy(i => i) | ||
.Aggregate(string.Empty, (current, extension) => current.Append(extension, ", ")); | ||
} | ||
return p.ToString(); | ||
})); | ||
|
||
return PortalSecurity.Instance.Encrypt(GetDecryptionKey(), checkString); | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
internal static bool ValidationCodeMatched(IList<object> parameters, string validationCode) | ||
{ | ||
return validationCode.Equals(ComputeValidationCode(parameters)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters