BccCode.Privacy.Hosting
0.13.1
See the version list below for details.
dotnet add package BccCode.Privacy.Hosting --version 0.13.1
NuGet\Install-Package BccCode.Privacy.Hosting -Version 0.13.1
<PackageReference Include="BccCode.Privacy.Hosting" Version="0.13.1" />
<PackageVersion Include="BccCode.Privacy.Hosting" Version="0.13.1" />
<PackageReference Include="BccCode.Privacy.Hosting" />
paket add BccCode.Privacy.Hosting --version 0.13.1
#r "nuget: BccCode.Privacy.Hosting, 0.13.1"
#:package BccCode.Privacy.Hosting@0.13.1
#addin nuget:?package=BccCode.Privacy.Hosting&version=0.13.1
#tool nuget:?package=BccCode.Privacy.Hosting&version=0.13.1
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.
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.
The one declaration (LIB-4)
A process is declared once, in a class: slug, id and key, name and purpose, bases per population, the Article 9
condition, the entities it uses, retention, variables and the adoption rule. Its vocabulary (Article 6 and 9 values,
retention units, variable types) is BccCode.Privacy.Client's; the application defines no enums of its own.
public static class Slugs { public const string ReferenceReview = "ateam-reference-review"; } // every use shares it
public sealed class ReferenceReview : PrivacyProcess
{
public override void Define(PrivacyProcessBuilder p) => p
.Slug(Slugs.ReferenceReview).Id(4).Key("ateam.reference_review")
.Name("Reference review").Purpose("EN", "Assess suitability for A-team at {organisation}")
.Population("applicants", "Applicants", a => a.Criteria("birthDate")) // optional: Criteria, Scopes, CoversWholePopulation
.Basis(PrivacyCatalogueLegalBasis.Contract, population: "applicants")
.Article9(PrivacyArticle9Condition.ExplicitConsent)
.Uses<ReferenceStatement>()
.Retention(2, PrivacyCatalogueRetentionUnit.Years, PrivacyCatalogueRetentionStart.RelationshipEnds)
.Variable("retention", PrivacyVariableType.Duration, "P2Y", maximum: "P2Y")
.AllowedAdopters(Orgs.ATeam); // one adopter: published as dataControllerId
}
// in the context: public PrivacyRules Rules { get; } = new PrivacyRules().Declare<ReferenceReview>();
Declare<T>() gives the rules the id, key and entities (the read filter and the write guard use them). The rest is
published at deploy by the application 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 [--update-lock] |
The checks below, with no network call. Run it in CI on every pull request |
privacy publish [--revision-file f] |
The checks, then items and processes sent to Privacy (idempotent per resource); prints the revision. Set BccPrivacy:AcceptedRevision to it for the build; start-up compares |
Checks: a slug (lower-case letters, digits, hyphens), name and purpose; at least one basis, each for a declared
population; an Article 9 condition when an entity is EnforcedInDatabase(), the process is marked SpecialCategory() or
an item is classified SensitivePersonalData; every entity mapped with Personal(...) and every named item mapped to
columns; retention present; every variable with a default, retention at most the process's retention; every {text parameter} a declared variable or a built-in (organisation, system); 9(2)(d) only with "within the body"; a
processor without a disclosure basis; a joint process with its arrangement; a published id never reused or renumbered
(the lock file privacy/published.json, append-only, committed: privacy check --update-lock adds new processes).
Without a declared disclosure basis, consent is published (with 9(2)(a) for special-category data).
The GitHub action .github/actions/privacy runs either command (command: check on pull requests, command: publish
in the deploy; output revision).
Every process is declared this way. A process added with rules.Process(...) and no PrivacyProcess class is a
problem: there are no definition files and no definitions in configuration.
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.
Items and notices, in code
Data items the application defines, and its data controller's privacy notice, are declared in code; configuration cannot declare them.
builder.Services.AddPrivacy<AppDbContext>(o => o
.Item("dietary-needs", new() { Name = "Dietary needs", Classification = "SensitivePersonalData",
Scopes = ["persons.dietary#read"], Names = { ["NO"] = "Kostbehov" } })
.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 items first, then processes (naming items by id), then the notice. An item a process uses that
the application does not define is looked up by name in Privacy's catalogue. 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, item or notice can change it.
Removed processes
After publishing, privacy publish 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 printed. 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 | |
|---|---|---|---|
| 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 | Versions 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. |
-
net10.0
- BccCode.ChangeHistory (>= 0.4.68)
- BccCode.Platform.Apis (>= 2.0.0.22)
- BccCode.Platform.Config (>= 2.0.0.22)
- BccCode.Privacy (>= 0.13.1)
- BccCode.Privacy.AspNetCore (>= 0.13.1)
- BccCode.Privacy.ChangeHistory (>= 0.13.1)
- BccCode.Privacy.Client (>= 0.1.22)
- BccCode.Privacy.EntityFrameworkCore (>= 0.13.1)
- BccCode.Privacy.Wolverine (>= 0.13.1)
- BccCode.PubSub.Client (>= 1.0.49)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.15)
- Microsoft.Extensions.Compliance.Abstractions (>= 10.11.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.3)
- WolverineFx (>= 6.64.0)
- WolverineFx.Http (>= 6.64.0)
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 |