Regulation Bridge
Why a bridge?
Section titled “Why a bridge?”Granit.Http.Cookies must not depend on Granit.Privacy.Regulations — the cookie
module is a general-purpose HTTP concern, not a privacy-specific one. The bridge
package Granit.Privacy.Regulations.Cookies connects them using the Dependency
Inversion Principle.
Granit.Http.Cookies defines: ICookieConsentModelProvider (interface) uses: ConsentModelInfo (DTO)
Granit.Privacy.Regulations.Cookies (bridge) implements: RegulationBasedCookieConsentModelProvider reads: IPrivacyRegulationResolver → PrivacyRegulationProfile maps: ConsentModel → CookieConsentMode// In your application modulecontext.Services.AddGranitRegulationCookiesBridge();This replaces the default NullCookieConsentModelProvider with the regulation-aware
provider. The GranitCookieManager will then consult the tenant’s regulation profile
to determine GPC enforcement and consent model.
How it works
Section titled “How it works”GranitCookieManagercallsICookieConsentModelProvider.GetConsentModelAsync()RegulationBasedCookieConsentModelProviderresolves the tenant’s regulation viaIPrivacyRegulationResolver- Maps
ConsentModel.OptOut→CookieConsentMode.OptOut(and similar) - Returns
ConsentModelInfo(Mode, HonorGlobalPrivacyControl)to the cookie manager - Result is memoized per request in
HttpContext.Itemsto avoid repeated resolver calls