Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/main/java/org/prebid/server/bidder/Usersyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Value;
import org.prebid.server.spring.config.bidder.model.usersync.CookieFamilySource;

import java.util.List;

@Value(staticConstructor = "of")
public class Usersyncer {

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

UsersyncMethod redirect;

public static Usersyncer of(String cookieFamilyName, UsersyncMethod iframe, UsersyncMethod redirect) {
return of(true, cookieFamilyName, CookieFamilySource.ROOT, iframe, redirect);
boolean skipWhenInGdprScope;

List<Integer> gppSidToSkip;

public static Usersyncer of(String cookieFamilyName,
UsersyncMethod iframe,
UsersyncMethod redirect,
boolean skipWhenInGdprScope,
List<Integer> gppSidToSkip) {

return of(
true,
cookieFamilyName,
CookieFamilySource.ROOT,
iframe,
redirect,
skipWhenInGdprScope,
gppSidToSkip);
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/prebid/server/cookie/CookieSyncService.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public Future<CookieSyncContext> processContext(CookieSyncContext cookieSyncCont
.map(this::filterDisabledBidders)
.map(this::filterBiddersWithoutUsersync)
.map(this::filterBiddersWithDisabledUsersync)
.map(this::filterBiddersByGdpr)
.map(this::filterBiddersByGppSid)
.map(this::applyRequestFilterSettings)
.compose(this::applyPrivacyFilteringRules)
.map(this::filterInSyncBidders);
Expand Down Expand Up @@ -202,6 +204,26 @@ private CookieSyncContext filterBiddersWithDisabledUsersync(CookieSyncContext co
RejectionReason.DISABLED_USERSYNC);
}

private CookieSyncContext filterBiddersByGdpr(CookieSyncContext cookieSyncContext) {
return filterBidders(
cookieSyncContext,
bidder -> cookieSyncContext.getPrivacyContext().getTcfContext().isInGdprScope()
&& bidderCatalog.usersyncerByName(bidder).map(Usersyncer::isSkipWhenInGdprScope).orElse(false),
RejectionReason.REJECTED_BY_REGULATION_SCOPE);
}

private CookieSyncContext filterBiddersByGppSid(CookieSyncContext cookieSyncContext) {
return filterBidders(
cookieSyncContext,
bidder -> bidderCatalog.usersyncerByName(bidder)
.map(Usersyncer::getGppSidToSkip)
.map(gppSid -> !Collections.disjoint(
gppSid,
cookieSyncContext.getCookieSyncRequest().getGppSid()))
.orElse(false),
RejectionReason.REJECTED_BY_REGULATION_SCOPE);
}

/**
* should be called after applying request filter, as it will populate usersync data
*/
Expand Down Expand Up @@ -469,6 +491,8 @@ private BidderUsersyncStatus rejectionStatus(String bidder, RejectionReason reas
case DISABLED_USERSYNC -> builder.conditionalError(requested || coopSync, "Sync disabled by config");
case REJECTED_BY_FILTER -> builder.conditionalError(requested || coopSync, "Rejected by request filter");
case ALREADY_IN_SYNC -> builder.conditionalError(requested, "Already in sync");
case REJECTED_BY_REGULATION_SCOPE -> builder.conditionalError(
requested || coopSync, "Rejected by regulation scope");
};

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public enum RejectionReason {
UNCONFIGURED_USERSYNC,
DISABLED_USERSYNC,
REJECTED_BY_FILTER,
ALREADY_IN_SYNC
ALREADY_IN_SYNC,
REJECTED_BY_REGULATION_SCOPE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.prebid.server.spring.config.bidder.model.usersync;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class UsersyncBidderRegulationScopeProperties {

boolean gdpr;

List<Integer> gppSid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public class UsersyncConfigurationProperties {
UsersyncMethodConfigurationProperties redirect;

UsersyncMethodConfigurationProperties iframe;

UsersyncBidderRegulationScopeProperties skipwhen;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.prebid.server.bidder.UsersyncUtil;
import org.prebid.server.bidder.Usersyncer;
import org.prebid.server.spring.config.bidder.model.usersync.CookieFamilySource;
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncBidderRegulationScopeProperties;
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncConfigurationProperties;
import org.prebid.server.spring.config.bidder.model.usersync.UsersyncMethodConfigurationProperties;
import org.prebid.server.util.HttpUtil;
Expand All @@ -30,13 +31,16 @@ private static Usersyncer createAndValidate(UsersyncConfigurationProperties user
String externalUrl) {

final String cookieFamilyName = usersync.getCookieFamilyName();
final UsersyncBidderRegulationScopeProperties skipwhenConfig = usersync.getSkipwhen();

return Usersyncer.of(
usersync.getEnabled(),
cookieFamilyName,
cookieFamilySource,
toMethod(UsersyncMethodType.IFRAME, usersync.getIframe(), cookieFamilyName, externalUrl),
toMethod(UsersyncMethodType.REDIRECT, usersync.getRedirect(), cookieFamilyName, externalUrl));
toMethod(UsersyncMethodType.REDIRECT, usersync.getRedirect(), cookieFamilyName, externalUrl),
skipwhenConfig != null && skipwhenConfig.isGdpr(),
skipwhenConfig == null ? null : skipwhenConfig.getGppSid());
}

private static UsersyncMethod toMethod(UsersyncMethodType type,
Expand Down
Loading
Loading