-
Notifications
You must be signed in to change notification settings - Fork 749
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
Remove GDPR TCF1 #1854
Merged
Merged
Remove GDPR TCF1 #1854
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7088319
Remove TCF v1
bsardo d060186
Fix misspelled purpose one treatment in config
bsardo 00e7692
Remove TCF2 references in tests
bsardo 239f969
Remove TCF1 references in metrics
bsardo 274c354
Maintain purpose_one_treatment config backwards compatibility
bsardo 7683071
Add TCF1 consent string unit test
bsardo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ import ( | |
"fmt" | ||
|
||
"github.com/prebid/go-gdpr/api" | ||
tcf1constants "github.com/prebid/go-gdpr/consentconstants" | ||
consentconstants "github.com/prebid/go-gdpr/consentconstants/tcf2" | ||
"github.com/prebid/go-gdpr/consentconstants" | ||
tcf2ConsentConstants "github.com/prebid/go-gdpr/consentconstants/tcf2" | ||
"github.com/prebid/go-gdpr/vendorconsent" | ||
tcf2 "github.com/prebid/go-gdpr/vendorconsent/tcf2" | ||
"github.com/prebid/go-gdpr/vendorlist" | ||
|
@@ -116,23 +116,20 @@ func (p *permissionsImpl) allowSync(ctx context.Context, vendorID uint16, consen | |
return false, nil | ||
} | ||
|
||
// InfoStorageAccess is the same across TCF 1 and TCF 2 | ||
if parsedConsent.Version() == 2 { | ||
if !p.cfg.TCF2.Purpose1.Enabled { | ||
// We are not enforcing purpose 1 | ||
return true, nil | ||
} | ||
consent, ok := parsedConsent.(tcf2.ConsentMetadata) | ||
if !ok { | ||
err := fmt.Errorf("Unable to access TCF2 parsed consent") | ||
return false, err | ||
} | ||
return p.checkPurpose(consent, vendor, vendorID, consentconstants.InfoStorageAccess, false), nil | ||
if parsedConsent.Version() != 2 { | ||
return false, nil | ||
} | ||
if vendor.Purpose(consentconstants.InfoStorageAccess) && parsedConsent.PurposeAllowed(consentconstants.InfoStorageAccess) && parsedConsent.VendorConsent(vendorID) { | ||
|
||
if !p.cfg.TCF2.Purpose1.Enabled { | ||
// We are not enforcing purpose 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO the code is clear enough such that the comment isn't necessary. |
||
return true, nil | ||
} | ||
return false, nil | ||
consentMeta, ok := parsedConsent.(tcf2.ConsentMetadata) | ||
if !ok { | ||
err := fmt.Errorf("Unable to access TCF2 parsed consent") | ||
return false, err | ||
} | ||
return p.checkPurpose(consentMeta, vendor, vendorID, tcf2ConsentConstants.InfoStorageAccess, false), nil | ||
} | ||
|
||
func (p *permissionsImpl) allowActivities(ctx context.Context, vendorID uint16, consent string, weakVendorEnforcement bool) (allowBidRequest bool, passGeo bool, passID bool, err error) { | ||
|
@@ -145,40 +142,28 @@ func (p *permissionsImpl) allowActivities(ctx context.Context, vendorID uint16, | |
return false, false, false, nil | ||
} | ||
|
||
if parsedConsent.Version() == 2 { | ||
if p.cfg.TCF2.Enabled { | ||
return p.allowActivitiesTCF2(parsedConsent, vendor, vendorID, weakVendorEnforcement) | ||
} | ||
if (vendor.Purpose(consentconstants.InfoStorageAccess) || vendor.LegitimateInterest(consentconstants.InfoStorageAccess) || weakVendorEnforcement) && parsedConsent.PurposeAllowed(consentconstants.InfoStorageAccess) && (vendor.Purpose(consentconstants.PersonalizationProfile) || vendor.LegitimateInterest(consentconstants.PersonalizationProfile) || weakVendorEnforcement) && parsedConsent.PurposeAllowed(consentconstants.PersonalizationProfile) && (parsedConsent.VendorConsent(vendorID) || weakVendorEnforcement) { | ||
return true, true, true, nil | ||
} | ||
} else { | ||
if (vendor.Purpose(tcf1constants.InfoStorageAccess) || vendor.LegitimateInterest(tcf1constants.InfoStorageAccess)) && parsedConsent.PurposeAllowed(tcf1constants.InfoStorageAccess) && (vendor.Purpose(tcf1constants.AdSelectionDeliveryReporting) || vendor.LegitimateInterest(tcf1constants.AdSelectionDeliveryReporting)) && parsedConsent.PurposeAllowed(tcf1constants.AdSelectionDeliveryReporting) && parsedConsent.VendorConsent(vendorID) { | ||
return true, true, true, nil | ||
} | ||
if parsedConsent.Version() != 2 || !p.cfg.TCF2.Enabled { | ||
return true, false, false, nil | ||
} | ||
return true, false, false, nil | ||
} | ||
|
||
func (p *permissionsImpl) allowActivitiesTCF2(parsedConsent api.VendorConsents, vendor api.Vendor, vendorID uint16, weakVendorEnforcement bool) (allowBidRequest bool, passGeo bool, passID bool, err error) { | ||
consent, ok := parsedConsent.(tcf2.ConsentMetadata) | ||
consentMeta, ok := parsedConsent.(tcf2.ConsentMetadata) | ||
if !ok { | ||
err = fmt.Errorf("Unable to access TCF2 parsed consent") | ||
return | ||
} | ||
|
||
if p.cfg.TCF2.SpecialPurpose1.Enabled { | ||
passGeo = consent.SpecialFeatureOptIn(1) && (vendor.SpecialPurpose(1) || weakVendorEnforcement) | ||
passGeo = consentMeta.SpecialFeatureOptIn(1) && (vendor.SpecialPurpose(1) || weakVendorEnforcement) | ||
} else { | ||
passGeo = true | ||
} | ||
if p.cfg.TCF2.Purpose2.Enabled { | ||
allowBidRequest = p.checkPurpose(consent, vendor, vendorID, tcf1constants.Purpose(2), weakVendorEnforcement) | ||
allowBidRequest = p.checkPurpose(consentMeta, vendor, vendorID, consentconstants.Purpose(2), weakVendorEnforcement) | ||
} else { | ||
allowBidRequest = true | ||
} | ||
for i := 2; i <= 10; i++ { | ||
if p.checkPurpose(consent, vendor, vendorID, tcf1constants.Purpose(i), weakVendorEnforcement) { | ||
if p.checkPurpose(consentMeta, vendor, vendorID, consentconstants.Purpose(i), weakVendorEnforcement) { | ||
passID = true | ||
break | ||
} | ||
|
@@ -191,8 +176,8 @@ const pubRestrictNotAllowed = 0 | |
const pubRestrictRequireConsent = 1 | ||
const pubRestrictRequireLegitInterest = 2 | ||
|
||
func (p *permissionsImpl) checkPurpose(consent tcf2.ConsentMetadata, vendor api.Vendor, vendorID uint16, purpose tcf1constants.Purpose, weakVendorEnforcement bool) bool { | ||
if purpose == consentconstants.InfoStorageAccess && p.cfg.TCF2.PurposeOneTreatment.Enabled && consent.PurposeOneTreatment() { | ||
func (p *permissionsImpl) checkPurpose(consent tcf2.ConsentMetadata, vendor api.Vendor, vendorID uint16, purpose consentconstants.Purpose, weakVendorEnforcement bool) bool { | ||
if purpose == tcf2ConsentConstants.InfoStorageAccess && p.cfg.TCF2.PurposeOneTreatment.Enabled && consent.PurposeOneTreatment() { | ||
return p.cfg.TCF2.PurposeOneTreatment.AccessAllowed | ||
} | ||
if consent.CheckPubRestriction(uint8(purpose), pubRestrictNotAllowed, vendorID) { | ||
|
@@ -224,7 +209,7 @@ func (p *permissionsImpl) parseVendor(ctx context.Context, vendorID uint16, cons | |
} | ||
|
||
version := parsedConsent.Version() | ||
if version < 1 || version > 2 { | ||
if version != 2 { | ||
return | ||
} | ||
vendorList, err := p.fetchVendorList[version](ctx, parsedConsent.VendorListVersion()) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for changing this name to tcf2 specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to maintain the differentiation between the
consentconstants
andconsentconstants/tcf2
packages while removing any reference to tcf1 so I renamed both of these.