github.com/prebid/prebid-server/v2@v2.18.0/gdpr/basic_enforcement.go (about) 1 package gdpr 2 3 import ( 4 tcf2 "github.com/prebid/go-gdpr/vendorconsent/tcf2" 5 ) 6 7 // BasicEnforcement determines if legal basis is satisfied for a given purpose and bidder/analytics adapter using 8 // the TCF2 basic enforcement algorithm. The algorithm is a high-level mode of consent confirmation 9 // that looks for a good-faith indication that the user has provided consent or legal basis signals 10 // necessary to perform a privacy-protected activity. The algorithm does not involve the GVL. 11 // BasicEnforcement implements the PurposeEnforcer interface 12 type BasicEnforcement struct { 13 cfg purposeConfig 14 } 15 16 // LegalBasis determines if legal basis is satisfied for a given purpose and bidder/analytics adapter based on user consent 17 // and legal basis signals. 18 func (be *BasicEnforcement) LegalBasis(vendorInfo VendorInfo, name string, consent tcf2.ConsentMetadata, overrides Overrides) bool { 19 enforcePurpose, enforceVendors := be.applyEnforceOverrides(overrides) 20 21 if !enforcePurpose && !enforceVendors { 22 return true 23 } 24 if be.cfg.vendorException(name) && !overrides.blockVendorExceptions { 25 return true 26 } 27 if !enforcePurpose && be.cfg.basicEnforcementVendor(name) { 28 return true 29 } 30 if enforcePurpose && consent.PurposeAllowed(be.cfg.PurposeID) && be.cfg.basicEnforcementVendor(name) { 31 return true 32 } 33 if enforcePurpose && consent.PurposeLITransparency(be.cfg.PurposeID) && overrides.allowLITransparency { 34 return true 35 } 36 if enforcePurpose && !consent.PurposeAllowed(be.cfg.PurposeID) { 37 return false 38 } 39 if !enforceVendors { 40 return true 41 } 42 return consent.VendorConsent(vendorInfo.vendorID) 43 } 44 45 // applyEnforceOverrides returns the enforce purpose and enforce vendor configuration values unless 46 // those values have been overridden, in which case they return true 47 func (be *BasicEnforcement) applyEnforceOverrides(overrides Overrides) (enforcePurpose, enforceVendors bool) { 48 enforcePurpose = be.cfg.EnforcePurpose 49 if overrides.enforcePurpose { 50 enforcePurpose = true 51 } 52 enforceVendors = be.cfg.EnforceVendors 53 if overrides.enforceVendors { 54 enforceVendors = true 55 } 56 return 57 }