BccCode.Privacy.Hosting 0.27.1

dotnet add package BccCode.Privacy.Hosting --version 0.27.1
                    
NuGet\Install-Package BccCode.Privacy.Hosting -Version 0.27.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BccCode.Privacy.Hosting" Version="0.27.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BccCode.Privacy.Hosting" Version="0.27.1" />
                    
Directory.Packages.props
<PackageReference Include="BccCode.Privacy.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BccCode.Privacy.Hosting --version 0.27.1
                    
#r "nuget: BccCode.Privacy.Hosting, 0.27.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BccCode.Privacy.Hosting@0.27.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BccCode.Privacy.Hosting&version=0.27.1
                    
Install as a Cake Addin
#tool nuget:?package=BccCode.Privacy.Hosting&version=0.27.1
                    
Install as a Cake Tool

BccCode.Privacy.Hosting

Changes in 0.14. The final design (design, plan) replaces parts of this API: the one declaration (Define, .Id, .Population, .Basis, .Article9, .Uses<T>, the lock file), o.Item(…), .AllowedAdopters, .NoAdoptionOnFirstRequest(), WithPrivacyLogin and UsePrivacyChangeHistory() are replaced by data classes and process declarations, PrivacyCatalogue.*/app PersonalDataCategory constants, AdoptableBy, AdoptOnFirstUse(), RequestConsentAtLogin<TProcess>() and automatic ChangeHistory registration; RemoveUndeclaredProcesses stays. This README is rewritten with the code (plan steps 12–21).

One call that installs BCC Privacy in an application, and checks the application's processes at start-up. Start-up publishes nothing (since 0.6): publishing to the Privacy API belongs to the deploy. Part of the BCC Privacy package family: it brings the core, EntityFrameworkCore, AspNetCore, Wolverine and BccCode.Privacy.Client.

builder.Services.AddDbContext<AppDbContext>(o => o.UseNpgsql(connectionString).UsePrivacy());
builder.Services.AddPrivacy<AppDbContext>(o => o.Application = "events");
// ...
app.UseAuthentication();
app.UsePrivacy();
app.MapPrivacyDocument();                    // GET /.well-known/bcc-privacy

The privacy document names tables and columns. Outside development and local runs it needs an authenticated caller (401 otherwise), so app.UseAuthentication() must come before it; in development it is open. Override with BccPrivacy:DocumentRequiresAuthentication.

With ChangeHistory (decision Q): AddPrivacy also registers the typed adapter's reader scope (BccCode.Privacy.ChangeHistory: events and history are read for the acting organisation). A context that derives from ChangeHistoryDbContext and has personal tables must call modelBuilder.UsePrivacyChangeHistory() last in ConfigureEntities; without it, or with another reader scope registered, start-up fails in every environment.

Declarations: data classes and processes (LIB-23)

The application declares what each entity holds in data classes (PrivacyData<T>, PrivacyChildData<T, TParentData>) and what each process keeps, about whom, why and for how long in process classes (PrivacyProcess, PrivacySubProcess<T>), all in BccCode.Privacy. Hosting reads them from the assemblies or types it is given:

builder.Services.AddPrivacy<AppDbContext>(o => o.Declare(typeof(ApplicationData).Assembly));   // BccPrivacy:AppSlug, e.g. "ateam"

Start-up runs the model checks in every environment: an entity field in no personal data category (PRIVACY001) and the other errors (PRIVACY002 and on) stop start-up with a PrivacyModelException that lists them all; overlaps between processes are logged as information. Keys, navigations, tables and columns come from the context's EF model.

At deploy the application publishes the declarations itself, as jasper codegen is run:

var app = builder.Build();
if (await app.RunPrivacyCommandAsync(args)) return;    // dotnet run -- privacy check | privacy publish
Command What it does
privacy check The model checks, a data controller for every process, and the notices. Prints the overlaps, which process keeps each category longest, and, with a client, will delete process X for each of the application's processes in Privacy it no longer declares. Run it in CI on every pull request
privacy publish [--revision-file f] The checks, then the notices and one process document per process (entities with their tables and fields per category, the app's personal data categories, holdings, sub-processes, bases, grounds and the adoption rule); then deletes what is no longer declared. Prints the revision: set BccPrivacy:AcceptedRevision to it for the build; start-up compares

A process is published for BccPrivacy:DataControllerId, or else for its single AdoptableBy org. Slugs are the processes' names in Privacy; there is no lock file.

The runtime registry. Until the EF runtime moves to the new model, each process the runtime filters on is also registered with a PrivacyProcessDefinition (.Slug(…).Id(n).Key(…).Uses<T>()) and rules.Declare<T>(). It publishes nothing. A process added with rules.Process(...) without one is a problem.

Login: the processes and the organisation (B-6, c10)

.AllowedAdopters(...) without any organisation means only the data controller may adopt. Adoption on first request is on unless .NoAdoptionOnFirstRequest() turns it off, and it happens only for the organisation the login request names. The application names it on its challenge and passes it on to the authorize request:

await HttpContext.ChallengeAsync(new AuthenticationProperties { RedirectUri = "/" }
    .WithPrivacyLogin(organisation, [Slugs.Register], optional: [Slugs.Newsletter]));

options.Events.OnRedirectToIdentityProvider = context =>      // OpenID Connect
{
    foreach (var (name, value) in PrivacyLogin.ParametersOf(context.Properties)) context.ProtocolMessage.SetParameter(name, value);
    return Task.CompletedTask;
};

This sends processes, optional_processes and org. Processes without an organisation are refused when the challenge is built.

Notices, in code

The data controller's privacy notice is declared in code; configuration cannot declare it. Data categories are not declared here: they are PersonalDataCategory constants, published with the processes.

builder.Services.AddPrivacy<AppDbContext>(o => o
    .Notice("privacy-policy", new() { Name = "Privacy policy", Url = "https://example.org/privacy",
        Urls = { ["NO"] = "https://example.org/personvern" } }));   // DataControllerId: default BccPrivacy:DataControllerId

privacy publish sends the notice before the processes. A data controller has one notice: two declared for the same controller is a problem. When the controller's notice already belongs to another application or the administrators, it is left alone and the publish reports a warning.

Ownership

Privacy records the owner of what the application pushes by its AppUID, the app_uid claim of its token, as Core API does. Ask for the AppUID to be added to the client's machine claims in sign-on; a push without it is refused (403). Only the application that created a process or notice can change it.

Removed processes

Set BccPrivacy:RemoveUndeclaredProcesses to true to let privacy publish delete processes the application no longer declares. Privacy refuses to delete a process people have consented to (409); such a process is kept, and a warning is printed. Processes owned by another application or by the administrators are never touched.

Per environment

The defaults follow the BCC platform environment: BccPlatform:HostingEnvironment (Prod, Dev, Local) when set, otherwise BccPlatform:Environment. ASP.NET Core's environment name does not count.

Dev, Local (or Environment Dev, Emulator) Sandbox, Staging Prod
Declarations checked Yes, logged Yes, logged Yes; a problem stops start-up
Compared with BccPrivacy:AcceptedRevision Yes, logged Yes; missing or different stops start-up Yes; missing or different stops start-up
Published to Privacy Never at start-up Never at start-up Never at start-up

Start-up calls no other service, so an unreachable Privacy API never stops it. The deploy publishes the definitions and records the revision Privacy accepted in BccPrivacy:AcceptedRevision; start-up compares the local definitions with it. Missing or different, start-up stops everywhere but development and local runs, where it is logged.

With no platform environment, start-up stops and names the settings, unless BccPrivacy:FailOnError is set. In Prod, a missing setting stops start-up: a process without a definition, a process without a data controller (and no BccPrivacy:DataControllerId), or definitions that differ from the accepted revision. Override with BccPrivacy:FailOnError.

Release note: 0.6

Start-up no longer pushes processes and items to Privacy (LIB-15). Every restart depended on the Privacy API, and a failed push could leave a half-published set. Publish at deploy instead (privacy publish, LIB-4) and set BccPrivacy:AcceptedRevision to the revision it reports; without it, start-up stops outside development. BccPrivacy:Push is removed. An item name the catalogue does not know is no longer found at start-up; the publish step finds it. PrivacyPusher stays for callers that publish themselves.

Version 0.x. Licence: Apache 2.0. Source: bcc-code/bcc-privacy, libraries/dotnet.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.27.1 0 11/24/2026
0.27.0 0 11/24/2026
0.26.0 0 11/24/2026
0.25.1 0 11/24/2026
0.25.0 10 11/24/2026
0.24.0 10 11/24/2026
0.23.6 12 11/24/2026
0.23.5 10 11/24/2026
0.23.4 11 11/24/2026
0.23.3 58 11/24/2026
0.23.2 55 11/24/2026
0.23.1 65 11/24/2026
0.23.0 61 11/24/2026
0.22.0 65 11/24/2026
0.21.0 73 11/23/2026
0.20.0 69 11/23/2026
0.19.0 67 11/23/2026
0.18.0 74 11/23/2026
0.17.0 64 11/23/2026
0.16.0 73 11/23/2026
Loading failed