mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 03:14:10 +08:00
Adding IEncryptionServices
Implements symetric encoding/decoding services based on a per-tenant key generated randomly during setup in the ShellSettings. Replaces MachineKey.Encode/Decode usages. Adding ComputedField to wrap get/set calls from parts, making the Smtp password encrypted in the db automatically. --HG-- branch : dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
@@ -29,6 +30,7 @@ using Orchard.Settings;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Themes.Services;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets;
|
||||
|
||||
@@ -118,6 +120,21 @@ namespace Orchard.Setup.Services {
|
||||
shellSettings.DataTablePrefix = context.DatabaseTablePrefix;
|
||||
}
|
||||
|
||||
#region Encryption Settings
|
||||
|
||||
// generate random keys for encryption
|
||||
var key = new byte[32];
|
||||
var iv = new byte[16];
|
||||
using ( var random = new RNGCryptoServiceProvider() ) {
|
||||
random.GetBytes(key);
|
||||
random.GetBytes(iv);
|
||||
}
|
||||
|
||||
shellSettings.EncryptionAlgorithm = "AES";
|
||||
shellSettings.EncryptionKey = key.ToHexString();
|
||||
shellSettings.EncryptionIV = iv.ToHexString();
|
||||
#endregion
|
||||
|
||||
var shellDescriptor = new ShellDescriptor {
|
||||
Features = context.EnabledFeatures.Select(name => new ShellFeature { Name = name })
|
||||
};
|
||||
|
Reference in New Issue
Block a user