GitXplorerGitXplorer
r

sanitiser

public
1 stars
0 forks
1 issues

Commits

List of commits on branch main.
Verified
fc49393ac2e711f4bff5c90b5296c3f20c58884a

Merge pull request #25 from richarth/dependabot/nuget/src/Sanitiser.TestSite.V10/Umbraco.Cms-10.8.7

rricharth committed 3 months ago
Verified
005f67690975d42a6c7df7de6294630f5d772c79

Bump Umbraco.Cms from 10.8.5 to 10.8.7 in /src/Sanitiser.TestSite.V10

ddependabot[bot] committed 3 months ago
Verified
015c93c52f25410bbd7a267057e69885607586b1

Merge pull request #24 from richarth/develop

rricharth committed 8 months ago
Unverified
57a4cc61e4ae1df572e9aa1f7ea1a6b20fcc75e8

Umbraco Marketplace readme

rricharth committed 8 months ago
Verified
8415d5360b208d7028ef3993b23ff4a43a94b82a

Merge pull request #23 from richarth/develop

rricharth committed 8 months ago
Unverified
eaf14f9e42f4f7f4b622dcd11653ac026926fe3a

Documented directory sanitisation

rricharth committed 8 months ago

README

The README file for this repository.

Sanitiser

Downloads NuGet GitHub license

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+

Installation

Add the package to your Umbraco website from nuget:

dotnet add package Umbraco.Community.Sanitiser

Configuration

To enable the package, add the following to your appsettings.json:

{
  "Sanitiser": {
    "Enable": true
  }
}

Member Data

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"
        }
    }
}

Custom database tables

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;
    }
}

Directory sanitization

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.

Customisation

Custom sanitizer

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.

Custom sanitizer settings

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.

Acknowledgements

Logo

The package logo uses the Sanitiser ( by Manish Mittal) icon from the Noun Project, licensed under CC BY 3.0 US.

License

MIT License