Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCF Purpose 1 and Purpose 2 enforcement for Prebid v4.0 #5336

Merged
merged 25 commits into from
Jun 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3042c1c
TCF v2.0 enforcement
Fawke Apr 30, 2020
73d3b52
test/spec/modules/gdprEnforcement_spec.js
Fawke Apr 30, 2020
a49f7e1
add check for gdpr version
Fawke May 5, 2020
559724e
add logInfo message
Fawke May 5, 2020
d945a8a
remove comment and store value of PURPOSES in an object
Fawke May 7, 2020
06e46d2
add gvlid check
Fawke May 11, 2020
f1fcf31
merge with master - change in validateRules function
Fawke May 28, 2020
cc57db8
add unit tests for validateRules function
Fawke Jun 2, 2020
9b98e98
remove purposeId parameter from validateRules function
Fawke Jun 2, 2020
87cfe20
merge with master
Fawke Jun 4, 2020
859d782
add extra tests
Fawke Jun 4, 2020
4e3978c
merge with master
Fawke Jun 4, 2020
1a0f5a7
make failing unit test case pass
Fawke Jun 4, 2020
ae9a237
deprecate allowAuctionWithouConsent with tcf 2 workflow
Fawke Jun 5, 2020
82e80a8
add extra checks for defaults
Fawke Jun 5, 2020
5311bac
remove tcf 2 test page
Fawke Jun 5, 2020
358a556
add strict gvlid check
Fawke Jun 8, 2020
d584a35
add comments and shorten log messages
Fawke Jun 9, 2020
0b461fb
shorted log messages
Fawke Jun 9, 2020
32c0682
add unit tests for setEnforcementConfig
Fawke Jun 9, 2020
35a6729
Merge remote-tracking branch 'origin/prebid-4.0' into tcf-purpose2
Jun 13, 2020
e7f14c0
add gvlid for alias and gvlMapping support
Jun 15, 2020
d0abaf0
remove gvlid check
Fawke Jun 15, 2020
45e9fb6
add support to add gvlid for aliases
Jun 17, 2020
beb7b65
Merge branch 'tcf-purpose2' of github.com:prebid/Prebid.js into tcf-p…
Jun 17, 2020
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
Prev Previous commit
Next Next commit
add comments and shorten log messages
  • Loading branch information
Fawke committed Jun 9, 2020
commit d584a350a0a9f715287c169681b3805b807ef786
21 changes: 16 additions & 5 deletions modules/gdprEnforcement.js
Original file line number Diff line number Diff line change
@@ -49,7 +49,8 @@ function getGvlid(bidderCode) {
}

/**
* This function takes in a rule and consentData and validates against the consentData provided. If it returns true Prebid will allow the next call else it will log a warning
* This function takes in a rule and consentData and validates against the consentData provided. Depending on what it returns,
* the caller may decide to suppress a TCF-sensitive activity.
* @param {Object} rule - enforcement rules set in config
* @param {Object} consentData - gdpr consent data
* @param {string=} currentModule - Bidder code of the current module
@@ -64,13 +65,23 @@ export function validateRules(rule, consentData, currentModule, gvlId) {
return true;
}

// get data from the consent string
const purposeConsent = utils.deepAccess(consentData, `vendorData.purpose.consents.${purposeId}`);
const vendorConsent = utils.deepAccess(consentData, `vendorData.vendor.consents.${gvlId}`);
const liTransparency = utils.deepAccess(consentData, `vendorData.purpose.legitimateInterests.${purposeId}`);

/*
Since vendor exceptions have already been handled, the purpose as a whole is allowed if it's not being enforced
or the user has consented. Similar with vendors.
*/
const purposeAllowed = rule.enforcePurpose === false || purposeConsent === true;
const vendorAllowed = rule.enforceVendor === false || vendorConsent === true;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: "Few if any vendors will be declaring Legitimate Interest for Purpose 1 (Device Access). However, a number of them do declare LI for Purpose 2 (Basic Ads). So if LI has been established, allow the auction and let the server side sort out the legal basis."

Copy link
Contributor Author

@Fawke Fawke Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose this comment, which you mentioned earlier over this:

Comment: "Few if any vendors should be declaring Legitimate Interest for Device Access (Purpose 1), but some are claiming LI for Basic Ads (Purpose 2)". Prebid.js can't check to see who's declaring what legal basis, so if LI has been established for Purpose 2, allow the auction to take place and let the server sort out the legal basis calculation."

/*
Few if any vendors should be declaring Legitimate Interest for Device Access (Purpose 1), but some are claiming
LI for Basic Ads (Purpose 2). Prebid.js can't check to see who's declaring what legal basis, so if LI has been
established for Purpose 2, allow the auction to take place and let the server sort out the legal basis calculation.
*/
if (purposeId === 2) {
return (purposeAllowed && vendorAllowed) || (liTransparency === true);
}
@@ -105,7 +116,7 @@ export function deviceAccessHook(fn, gvlid, moduleName, result) {
result.valid = true;
fn.call(this, gvlid, moduleName, result);
} else {
curModule && utils.logWarn(`User denied Permission for Device access for ${curModule}`);
curModule && utils.logWarn(`Device access denied for ${curModule} by TCF2`);
result.valid = false;
fn.call(this, gvlid, moduleName, result);
}
@@ -203,7 +214,7 @@ export function makeBidRequestsHook(fn, adUnits, ...args) {
if (includes(disabledBidders, currBidder)) return false;
const isAllowed = gvlId && validateRules(purpose2Rule, consentData, currBidder, gvlId);
if (!isAllowed) {
utils.logWarn(`User blocked bidder: ${currBidder}. No bid request will be sent to their endpoint.`);
utils.logWarn(`TCF2 blocked auction for ${currBidder}`);
events.emit(EVENTS.BIDDER_BLOCKED, currBidder);
disabledBidders.push(currBidder);
}
@@ -212,7 +223,7 @@ export function makeBidRequestsHook(fn, adUnits, ...args) {
});
fn.call(this, adUnits, ...args);
} else {
utils.logInfo('Enforcing TCF2 only');
// we don't enforce TCF1.1 strings
fn.call(this, adUnits, ...args);
}
} else {
@@ -230,7 +241,7 @@ const hasPurpose2 = (rule) => { return rule.purpose === TCF2.purpose2.name }
export function setEnforcementConfig(config) {
const rules = utils.deepAccess(config, 'gdpr.rules');
if (!rules) {
utils.logWarn('GDPR enforcement rules not defined, enforcing TCF2 Purpose 1 and Purpose 2');
utils.logWarn('TCF2: enforcing P1 and P2');
enforcementRules = DEFAULT_RULES;
} else {
enforcementRules = rules;