BccCode.Privacy.AspNetCore
0.30.5
See the version list below for details.
dotnet add package BccCode.Privacy.AspNetCore --version 0.30.5
NuGet\Install-Package BccCode.Privacy.AspNetCore -Version 0.30.5
<PackageReference Include="BccCode.Privacy.AspNetCore" Version="0.30.5" />
<PackageVersion Include="BccCode.Privacy.AspNetCore" Version="0.30.5" />
<PackageReference Include="BccCode.Privacy.AspNetCore" />
paket add BccCode.Privacy.AspNetCore --version 0.30.5
#r "nuget: BccCode.Privacy.AspNetCore, 0.30.5"
#:package BccCode.Privacy.AspNetCore@0.30.5
#addin nuget:?package=BccCode.Privacy.AspNetCore&version=0.30.5
#tool nuget:?package=BccCode.Privacy.AspNetCore&version=0.30.5
BccCode.Privacy.AspNetCore
Changes in 0.14. The final design (design, plan) replaces parts of this API: response masking by item is dropped;
[PrivacyProcess<T>]sets the request's context, and the projection and guards in the EF adapter do the minimisation. This README is rewritten with the code (plan steps 12–21).
BCC Privacy for ASP.NET Core, minimal APIs and MVC. Part of the BCC Privacy package family; depends
on BccCode.Privacy only, not on EF Core.
builder.Services.AddPrivacyAspNetCore(o => o.OrganisationClaimType = "org"); // a scoped PrivacyScope per request
// ...
app.UseAuthentication();
app.UsePrivacy();
app.MapGet("/members", (AppDbContext db) => db.PersonProfiles.ToListAsync())
.WithPrivacyProcess(Processes.MembershipRegister, Items.Name); // the process, and the items it may return
[PrivacyProcess("membership.register")] // MVC: by id or by key
public sealed class MembersController : ControllerBase { /* ... */ }
public sealed record MemberDto(string Name, [property: PrivacyItem("birth_date")] DateOnly? BirthDate);
| Behaviour | |
|---|---|
| Organisation | From the signed-in user's org claim (configurable, or a function of the request). None: no personal rows |
| Organisation claim contract | The claim is issued by sign-on (or the application's own authentication) and names one organisation the user may act for; the package trusts its issuer for that. Where users choose an organisation, or the claim may name one the user does not belong to, set o.Authorise = (http, org) => ...: a false answer refuses the request with 403 before the endpoint runs. Single-controller mode (LIB-18) needs no claim |
| Process | From the endpoint: .WithPrivacyProcess(...) or [PrivacyProcess(...)], by id or by key (by key needs PrivacyRules registered) |
| An endpoint without a process that reads personal data | Refused with 403 and a message naming the endpoint and the fix. Endpoints that read no personal data are unaffected |
[PrivacyItem("x")] on a response property |
Left out of the JSON unless the endpoint lists item x. An endpoint that lists no items, an endpoint without a process, and serialisation outside a request return none |
Response masking is a convenience, not a control. It trims what an endpoint returns, but it does not decide what a
request may read: a response type without [PrivacyItem], a hand-written JSON body, a file or another serialiser is not
masked. The control is the EF Core package's read view, which returns an item another organisation has not shared as
NULL, so filtering, sorting and projecting cannot reveal it. The convenience denies by default: list the items an
endpoint returns.
Consent at login and on first need (c10)
builder.Services.AddAuthentication(...).AddOpenIdConnect(...)
.RequestConsentAtLogin<NewsletterProcess>(); // every sign-in asks this consent (a sub-process: its parent's)
await HttpContext.ChallengeAsync(new AuthenticationProperties { RedirectUri = "/" }
.WithPrivacyLogin(org, ["register"], optional: ["newsletter"])); // or name processes on one challenge
The OpenID Connect authorize request then carries processes, optional_processes and org; sign-in asks the consent
and returns. The org is the one passed, else the request's org; a challenge without an org is refused.
| Behaviour | |
|---|---|
| Person | From the claim https://login.bcc.no/claims/personUid (o.PersonClaimType) |
| A person saving their own row under a consent process without that consent | The EF adapter throws PrivacyConsentRequiredException. Staff saving other persons' rows, and reads, are never asked |
| ... on a GET | The middleware challenges the default scheme with the consent request, and returns to the request's URL |
| ... on another method | 403 application/problem+json (RFC 9457), type urn:bcc-privacy:consent-required, with process, org and signIn. The client sends the person to signIn with &returnUrl=<local URL> and retries. signIn (o.ConsentSignInPath, default /privacy/consent) starts sign-in with the consent request; it returns only to a local URL |
| Without a sign-in scheme | 403 consent-required problem without signIn |
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.Privacy (>= 0.30.5)
- BccCode.Privacy.Vocabulary (>= 1.0.20)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 10.0.15)
- Microsoft.Extensions.Compliance.Abstractions (>= 10.11.1)
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 |
|---|---|---|
| 8.0.1 | 45 | 11/26/2026 |
| 8.0.0 | 43 | 11/26/2026 |
| 7.1.0 | 43 | 11/26/2026 |
| 7.0.0 | 47 | 11/26/2026 |
| 6.0.2 | 48 | 11/26/2026 |
| 6.0.1 | 49 | 11/26/2026 |
| 6.0.0 | 45 | 11/26/2026 |
| 5.0.1 | 46 | 11/26/2026 |
| 5.0.0 | 45 | 11/26/2026 |
| 4.0.0 | 52 | 11/26/2026 |
| 3.0.0 | 46 | 11/26/2026 |
| 2.0.0 | 49 | 11/26/2026 |
| 1.0.0 | 50 | 11/26/2026 |
| 0.30.7 | 47 | 11/26/2026 |
| 0.30.6 | 48 | 11/26/2026 |
| 0.30.5 | 52 | 11/26/2026 |
| 0.30.4 | 42 | 11/26/2026 |
| 0.30.3 | 46 | 11/26/2026 |
| 0.30.2 | 52 | 11/26/2026 |
| 0.30.1 | 53 | 11/25/2026 |