Add geolocation-based privacy regulation detection to cookie banner
Resolve the visitor's IP to a country code via the geoloc service and map it to the applicable privacy regulation (GDPR, UK GDPR, FADP, CCPA, PIPEDA, LGPD, LFPDPPP, POPIA, PDPA, PIPL, PIPA, APPI, DPDP, PDPL). The regulation and its implied consent mode (OPT_IN / OPT_OUT) are injected into the GET /config response so the SDK can adapt its behavior. Also makes geoloc.Service self-contained: LookupCountry and IsPopulated now manage their own DB connections instead of requiring callers to pass a pg.Querier. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -262,21 +262,11 @@ func (impl *Implm) Run(
|
||||
}
|
||||
|
||||
geolocService := geoloc.NewService(pgClient)
|
||||
err = pgClient.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
populated, err := geolocService.IsPopulated(ctx, conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !populated {
|
||||
l.Warn("IP geolocation table is empty; run geoloc-import to populate it")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
populated, err := geolocService.IsPopulated(ctx)
|
||||
if err != nil {
|
||||
l.ErrorCtx(ctx, "cannot check geoloc table", log.Error(err))
|
||||
} else if !populated {
|
||||
l.Warn("IP geolocation table is empty; run geoloc-import to populate it")
|
||||
}
|
||||
|
||||
hp, err := passwdhash.NewProfile(pepper, uint32(impl.cfg.Auth.Password.Iterations))
|
||||
@@ -538,6 +528,7 @@ func (impl *Implm) Run(
|
||||
AccessReview: accessReviewService,
|
||||
Mailman: mailmanService,
|
||||
CookieBanner: cookieBannerService,
|
||||
Geoloc: geolocService,
|
||||
Slack: slackService,
|
||||
ConnectorRegistry: defaultConnectorRegistry,
|
||||
BaseURL: baseURL,
|
||||
|
||||
Reference in New Issue
Block a user