Skip to content

Privacy

Granit.Privacy implements GDPR data subject rights (Art. 15–18): data export orchestration via saga, right to erasure with cascading notifications, and legal agreement tracking.

  • Granit.Privacy GDPR data export saga, legal agreements, data provider registry
PackageRoleDepends on
Granit.PrivacyGDPR data export/deletion orchestration, legal agreementsGranit.Core
[DependsOn(typeof(GranitPrivacyModule))]
public class AppModule : GranitModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddGranitPrivacy(privacy =>
{
privacy.RegisterDataProvider("PatientModule");
privacy.RegisterDataProvider("BlobStorageModule");
privacy.RegisterDocument(
"privacy-policy", "2.1", "Privacy Policy");
privacy.RegisterDocument(
"terms-of-service", "1.0", "Terms of Service");
});
}
}

Modules register themselves as data providers to participate in GDPR data export and deletion workflows:

privacy.RegisterDataProvider("PatientModule");

When a data subject requests export or deletion, the saga queries all registered providers and waits for each to complete.

stateDiagram-v2
    [*] --> Requested: PersonalDataRequestedEvent
    Requested --> Collecting: Query all providers
    Collecting --> Prepared: PersonalDataPreparedEvent
    Prepared --> Completed: ExportCompletedEvent
    Collecting --> TimedOut: ExportTimedOutEvent
    Completed --> [*]
    TimedOut --> [*]

The export saga orchestrates data collection across all registered data providers. Each provider prepares its data independently, and the saga assembles the final export package.

sequenceDiagram
    participant User
    participant API
    participant Saga
    participant Identity
    participant BlobStorage
    participant Notifications

    User->>API: DELETE /privacy/my-data
    API->>Saga: PersonalDataDeletionRequestedEvent
    Saga->>Identity: DeleteByIdAsync (hard delete)
    Saga->>BlobStorage: Delete user blobs
    Saga->>Notifications: Delete delivery records
    Identity-->>Saga: IdentityUserDeletedEvent
    Saga->>User: Acknowledgment notification

Track consent to legal documents (privacy policy, terms of service):

privacy.RegisterDocument("privacy-policy", "2.1", "Privacy Policy");

Provide a store implementation to persist agreement records:

privacy.UseLegalAgreementStore<EfCoreLegalAgreementStore>();

ILegalAgreementChecker verifies if a user has signed the current version of a document — useful for middleware that blocks access until consent is renewed after a policy update.

{
"Privacy": {
"ExportTimeoutMinutes": 5,
"ExportMaxSizeMb": 100
}
}
CategoryKey typesPackage
ModuleGranitPrivacyModule
RegistryIDataProviderRegistry, ILegalDocumentRegistry, ILegalAgreementCheckerGranit.Privacy
BuilderGranitPrivacyBuilder, GranitPrivacyOptionsGranit.Privacy
EventsPersonalDataRequestedEvent, PersonalDataDeletionRequestedEvent, ExportCompletedEvent, ExportTimedOutEventGranit.Privacy
ExtensionsAddGranitPrivacy()Granit.Privacy