Skip to content

Commit 9ae1345

Browse files
Bidder Usersync Skipwhen Config (#3974)
1 parent dc16e98 commit 9ae1345

File tree

15 files changed

+482
-36
lines changed

15 files changed

+482
-36
lines changed

src/main/java/org/prebid/server/bidder/Usersyncer.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import lombok.Value;
44
import org.prebid.server.spring.config.bidder.model.usersync.CookieFamilySource;
55

6+
import java.util.List;
7+
68
@Value(staticConstructor = "of")
79
public class Usersyncer {
810

@@ -16,7 +18,23 @@ public class Usersyncer {
1618

1719
UsersyncMethod redirect;
1820

19-
public static Usersyncer of(String cookieFamilyName, UsersyncMethod iframe, UsersyncMethod redirect) {
20-
return of(true, cookieFamilyName, CookieFamilySource.ROOT, iframe, redirect);
21+
boolean skipWhenInGdprScope;
22+
23+
List<Integer> gppSidToSkip;
24+
25+
public static Usersyncer of(String cookieFamilyName,
26+
UsersyncMethod iframe,
27+
UsersyncMethod redirect,
28+
boolean skipWhenInGdprScope,
29+
List<Integer> gppSidToSkip) {
30+
31+
return of(
32+
true,
33+
cookieFamilyName,
34+
CookieFamilySource.ROOT,
35+
iframe,
36+
redirect,
37+
skipWhenInGdprScope,
38+
gppSidToSkip);
2139
}
2240
}

src/main/java/org/prebid/server/cookie/CookieSyncService.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public Future<CookieSyncContext> processContext(CookieSyncContext cookieSyncCont
111111
.map(this::filterDisabledBidders)
112112
.map(this::filterBiddersWithoutUsersync)
113113
.map(this::filterBiddersWithDisabledUsersync)
114+
.map(this::filterBiddersByGdpr)
115+
.map(this::filterBiddersByGppSid)
114116
.map(this::applyRequestFilterSettings)
115117
.compose(this::applyPrivacyFilteringRules)
116118
.map(this::filterInSyncBidders);
@@ -202,6 +204,26 @@ private CookieSyncContext filterBiddersWithDisabledUsersync(CookieSyncContext co
202204
RejectionReason.DISABLED_USERSYNC);
203205
}
204206

207+
private CookieSyncContext filterBiddersByGdpr(CookieSyncContext cookieSyncContext) {
208+
return filterBidders(
209+
cookieSyncContext,
210+
bidder -> cookieSyncContext.getPrivacyContext().getTcfContext().isInGdprScope()
211+
&& bidderCatalog.usersyncerByName(bidder).map(Usersyncer::isSkipWhenInGdprScope).orElse(false),
212+
RejectionReason.REJECTED_BY_REGULATION_SCOPE);
213+
}
214+
215+
private CookieSyncContext filterBiddersByGppSid(CookieSyncContext cookieSyncContext) {
216+
return filterBidders(
217+
cookieSyncContext,
218+
bidder -> bidderCatalog.usersyncerByName(bidder)
219+
.map(Usersyncer::getGppSidToSkip)
220+
.map(gppSid -> !Collections.disjoint(
221+
gppSid,
222+
cookieSyncContext.getCookieSyncRequest().getGppSid()))
223+
.orElse(false),
224+
RejectionReason.REJECTED_BY_REGULATION_SCOPE);
225+
}
226+
205227
/**
206228
* should be called after applying request filter, as it will populate usersync data
207229
*/
@@ -469,6 +491,8 @@ private BidderUsersyncStatus rejectionStatus(String bidder, RejectionReason reas
469491
case DISABLED_USERSYNC -> builder.conditionalError(requested || coopSync, "Sync disabled by config");
470492
case REJECTED_BY_FILTER -> builder.conditionalError(requested || coopSync, "Rejected by request filter");
471493
case ALREADY_IN_SYNC -> builder.conditionalError(requested, "Already in sync");
494+
case REJECTED_BY_REGULATION_SCOPE -> builder.conditionalError(
495+
requested || coopSync, "Rejected by regulation scope");
472496
};
473497

474498
return builder.build();

src/main/java/org/prebid/server/cookie/model/RejectionReason.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public enum RejectionReason {
1010
UNCONFIGURED_USERSYNC,
1111
DISABLED_USERSYNC,
1212
REJECTED_BY_FILTER,
13-
ALREADY_IN_SYNC
13+
ALREADY_IN_SYNC,
14+
REJECTED_BY_REGULATION_SCOPE
1415
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.prebid.server.spring.config.bidder.model.usersync;
2+
3+
import lombok.Data;
4+
import lombok.NoArgsConstructor;
5+
6+
import java.util.List;
7+
8+
@Data
9+
@NoArgsConstructor
10+
public class UsersyncBidderRegulationScopeProperties {
11+
12+
boolean gdpr;
13+
14+
List<Integer> gppSid;
15+
}

src/main/java/org/prebid/server/spring/config/bidder/model/usersync/UsersyncConfigurationProperties.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ public class UsersyncConfigurationProperties {
1919
UsersyncMethodConfigurationProperties redirect;
2020

2121
UsersyncMethodConfigurationProperties iframe;
22+
23+
UsersyncBidderRegulationScopeProperties skipwhen;
2224
}

src/main/java/org/prebid/server/spring/config/bidder/util/UsersyncerCreator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.prebid.server.bidder.UsersyncUtil;
77
import org.prebid.server.bidder.Usersyncer;
88
import org.prebid.server.spring.config.bidder.model.usersync.CookieFamilySource;
9+
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncBidderRegulationScopeProperties;
910
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncConfigurationProperties;
1011
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncMethodConfigurationProperties;
1112
import org.prebid.server.util.HttpUtil;
@@ -30,13 +31,16 @@ private static Usersyncer createAndValidate(UsersyncConfigurationProperties user
3031
String externalUrl) {
3132

3233
final String cookieFamilyName = usersync.getCookieFamilyName();
34+
final UsersyncBidderRegulationScopeProperties skipwhenConfig = usersync.getSkipwhen();
3335

3436
return Usersyncer.of(
3537
usersync.getEnabled(),
3638
cookieFamilyName,
3739
cookieFamilySource,
3840
toMethod(UsersyncMethodType.IFRAME, usersync.getIframe(), cookieFamilyName, externalUrl),
39-
toMethod(UsersyncMethodType.REDIRECT, usersync.getRedirect(), cookieFamilyName, externalUrl));
41+
toMethod(UsersyncMethodType.REDIRECT, usersync.getRedirect(), cookieFamilyName, externalUrl),
42+
skipwhenConfig != null && skipwhenConfig.isGdpr(),
43+
skipwhenConfig == null ? null : skipwhenConfig.getGppSid());
4044
}
4145

4246
private static UsersyncMethod toMethod(UsersyncMethodType type,

0 commit comments

Comments
 (0)