BccCode.Privacy.Hosting 0.8.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BccCode.Privacy.Hosting --version 0.8.0
                    
NuGet\Install-Package BccCode.Privacy.Hosting -Version 0.8.0
                    
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.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BccCode.Privacy.Hosting" Version="0.8.0" />
                    
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.8.0
                    
#r "nuget: BccCode.Privacy.Hosting, 0.8.0"
                    
#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.8.0
                    
#: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.8.0
                    
Install as a Cake Addin
#tool nuget:?package=BccCode.Privacy.Hosting&version=0.8.0
                    
Install as a Cake Tool

BccCode.Privacy.Hosting

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.

Definitions: processes and items

A process declared in code (rules.Process(3, new("registration"))) needs a definition: its purpose, legal basis and texts. Its code in Privacy is {application}-{key}, dots as hyphens: events-registration. Definitions come from any of these, as one JSON contract (the document of PUT /api/processes/{code} and PUT /api/items/{code}):

Source Example
Files: privacy/processes/<code>.md Markdown with YAML frontmatter, as Privacy's admin import reads it (texts per language under ## EN / ### Purpose)
Files: privacy/processes/<code>.json or .yml The same fields as JSON or YAML
Files: privacy/items/<code>.json or .yml name, classification, scopes, names, dataSource
Configuration BccPrivacy:Processes:<code>:..., BccPrivacy:Items:<code>:...
Code o.Process("events-registration", new() { ... }), o.Item(...)

A process names its data items by item code (defined by the application) or by name in Privacy's catalogue; they are resolved to ids when published. Set BccPrivacy:DataControllerId for processes that do not name their data controller.

A process may also declare its data subjects and retention, in any of the sources above:

dataSubjects:
  - name: Members              # code from the name when left out: members
    translations:              # in .json, configuration and code: names: { NO: Medlemmer }
      - language: NO
        name: Medlemmer
retention:                     # or: whileThePurposeLasts: true
  period: 5
  unit: years                  # months or years
  from: relationshipEnds       # collection, lastUse, relationshipEnds or other
  # fromText: [{ language: EN, text: after the last event attended }]   only with from: other

They are checked like the other fields: a group without a name, a code used twice, or a retention period without its unit or what it is counted from is a definition problem. They are sent with the process, like its other fields.

Privacy notices

An application may also declare its data controller's privacy notice, in the same sources (privacy/notices/<name>.json or .yml, BccPrivacy:Notices:<name>:..., or o.Notice("<name>", new() { ... })):

name: Privacy policy
url: https://example.org/privacy
names: { NO: Personvernerklæring }        # its name in other languages
urls: { NO: https://example.org/personvern }
# dataControllerId: ...                   # default BccPrivacy:DataControllerId

It is published (by the deploy step, after the processes) as the controller's notice, owned by the application. A data controller has one notice: two declared for the same controller is a definition 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, item or notice can change it.

Removed processes

Start-up pushes nothing (LIB-15). When the application publishes (PrivacyPusher.PushAsync), the library lists the processes Privacy records as the application's own and deletes each one it no longer declares. Privacy refuses to delete a process people have consented to (409); such a process is kept, and a warning is logged. Set BccPrivacy:RemoveUndeclaredProcesses to false to keep every process the application created. 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
Definitions checked against the code 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.13.3 59 11/19/2026
0.13.2 49 11/19/2026
0.13.1 51 11/19/2026
0.13.0 52 11/19/2026
0.12.0 54 11/19/2026
0.11.0 50 11/19/2026
0.10.0 48 11/18/2026
0.9.2 47 11/18/2026
0.9.1 51 11/18/2026
0.9.0 51 11/18/2026
0.8.1 45 11/18/2026
0.8.0 53 11/18/2026
0.7.0 50 11/18/2026
0.6.2 51 11/18/2026
0.6.1 51 11/18/2026
0.6.0 47 11/18/2026
0.5.7 52 11/18/2026
0.5.6 55 11/18/2026
0.5.5 52 11/18/2026
0.5.4 55 11/17/2026
Loading failed