When enabled, this package will automatically remove personal data from your Umbraco website on startup.
Out of the box the package will delete member data.
Umbraco versions supported: v10.8.5+
Add the package to your Umbraco website from nuget:
dotnet add package Umbraco.Community.Sanitiser
To enable the package, add the following to your appsettings.json
:
{
"Sanitiser": {
"Enable": true
}
}
To enable the deletion of member data, add the following to your appsettings.json
:
{
"Sanitiser": {
"Enable": true,
"MembersSanitiser": {
"Enable": true
}
}
}
To exclude members whose email addresses belong to specific domains from deletion, add the following to
your appsettings.json
:
{
"Sanitiser": {
"Enable": true,
"MembersSanitiser": {
"Enable": true,
"DomainsToExclude": "test.com,example.com"
}
}
}
To enable the deletion of data from custom database tables, you can extend the DatabaseTableSanitiser
class and create
a poco with a table name attribute.
For example, to have a table called test
automatically emptied on startup, create a poco like this:
using NPoco;
[TableName("test")]
public class Test;
And extend the DatabaseTableSanitiser
class like this with your poco class as a type parameter:
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Community.Sanitiser.Models;
namespace Umbraco.Community.Sanitiser.sanitisers;
public class TestTableSanitiser(IScopeProvider scopeProvider) : DatabaseTableSanitiser<Test>(scopeProvider)
{
public override bool IsEnabled()
{
return true;
}
}
To enable the deletion of files and folders in a directory, you can extend the DirectorySanitiser
class and implement the IsEnabled
and GetDirectoryPath
methods. GetDirectoryPath
should return the path you want clearing out. E.g.
using Umbraco.Community.Sanitiser.sanitisers;
public class MyCustomDirectorySanitiser : DirectorySanitiser
{
protected override string GetDirectoryPath()
{
return "wwwroot/media/forms/upload/";
}
public override bool IsEnabled()
{
return true;
}
}
Warning
N.B. This package is not intended to be run on production sites, only enable sanitization on a development or staging environment. Before enabling please ensure you have a backup of your data and a backup of your backup.
If there is a lot of data then the startup of your site may be delayed. Only enable when necessary.
To add your own sanitization logic, implement the ISanitiser
interface. Your sanitization logic will be run
automatically on startup when the sanitization service and your sanitizer are enabled.
Add your logic to the Sanitise
method.
You will also need to implement the enabled check in the IsEnabled
method. You could check for a value in Umbraco,
simply return true or more likely add a setting to appsettings.json
.
If adding your own setting(s) to the Sanitiser
section of appsettings.json
, you can add a new class which
extends SanitiserOptions
to automatically include your new settings. For example:
using Umbraco.Community.Sanitiser.Configuration;
public class MySanitiserOptions : SanitiserOptions
{
public MySettingsPoco Disable { get; init; }
}
public class MySettingsPoco
{
public bool Disable { get; init; }
}
You then need to add the following to your composer for your settings to be automatically configured:
// your extension of SanitiserOptions is passed as a type parameter
builder.Services.Configure<MySanitiserOptions>(
builder.Config.GetSection(SanitiserOptions.SanitiserOptionsKey));
If you were to add the following to your appsettings.json
:
{
"Sanitiser": {
"MySanitiserOptions": {
"Disable": true
}
}
}
The values from your appsettings.json
will be automatically
mapped to your extension of SanitiserOptions
.
The package logo uses the Sanitiser ( by Manish Mittal) icon from the Noun Project, licensed under CC BY 3.0 US.
MIT License