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

Pass Global Privacy Control header to bidders #1789

Merged
merged 9 commits into from
May 19, 2021
1 change: 1 addition & 0 deletions adapters/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (r *RequestData) SetBasicAuth(username string, password string) {

type ExtraRequestInfo struct {
PbsEntryPoint metrics.RequestType
SecGPCFlag string
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need to use the exact cookie name as the variable. IMHO, a more straight forward name, such as "GlobalPrivacyControl" or "GlobalPrivacyControlHeader" would be easier to read in adapter code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spending your time reviewing this draft PR. I am new to the community and I hope to contribute regularly. I have updated this with your recommendation. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Welcome to the community. We're very welcoming of new regular contributors. Please let us know via a comment on the GitHub Issues what you'd like to work on next so there's no duplicate effort.

}

type Builder func(openrtb_ext.BidderName, config.Adapter) (Bidder, error)
4 changes: 4 additions & 0 deletions endpoints/openrtb2/amp_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,17 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h
return
}

// #1712
secgpc := r.Header.Get("Sec-GPC")
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved

auctionRequest := exchange.AuctionRequest{
BidRequest: req,
Account: *account,
UserSyncs: usersyncs,
RequestType: labels.RType,
StartTime: start,
LegacyLabels: labels,
SecGPCFlag: secgpc,
}

response, err := deps.ex.HoldAuction(ctx, auctionRequest, nil)
Expand Down
4 changes: 4 additions & 0 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
return
}

// #1712
secgpc := r.Header.Get("Sec-GPC")

auctionRequest := exchange.AuctionRequest{
BidRequest: req,
Account: *account,
Expand All @@ -181,6 +184,7 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
StartTime: start,
LegacyLabels: labels,
Warnings: warnings,
SecGPCFlag: secgpc,
}

response, err := deps.ex.HoldAuction(ctx, auctionRequest, nil)
Expand Down
4 changes: 4 additions & 0 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,17 @@ func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Re
return
}

// #1712
secgpc := r.Header.Get("Sec-GPC")

auctionRequest := exchange.AuctionRequest{
BidRequest: bidReq,
Account: *account,
UserSyncs: usersyncs,
RequestType: labels.RType,
StartTime: start,
LegacyLabels: labels,
SecGPCFlag: secgpc,
}

response, err := deps.ex.HoldAuction(ctx, auctionRequest, &debugLog)
Expand Down
7 changes: 7 additions & 0 deletions exchange/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb2.B
return nil, errs
}

// #1712 add Sec-GPC to the headers if set in original request
if reqInfo.SecGPCFlag == "1" {
for i := 0; i < len(reqData); i++ {
reqData[i].Headers.Add("Sec-GPC", reqInfo.SecGPCFlag)
}
}
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved

// Make any HTTP requests in parallel.
// If the bidder only needs to make one, save some cycles by just using the current one.
responseChannel := make(chan *httpCallInfo, len(reqData))
Expand Down
6 changes: 4 additions & 2 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type AuctionRequest struct {
RequestType metrics.RequestType
StartTime time.Time
Warnings []error
SecGPCFlag string

// LegacyLabels is included here for temporary compatability with cleanOpenRTBRequests
// in HoldAuction until we get to factoring it away. Do not use for anything new.
Expand Down Expand Up @@ -172,7 +173,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog *
// Get currency rates conversions for the auction
conversions := e.currencyConverter.Rates()

adapterBids, adapterExtra, anyBidsReturned := e.getAllBids(auctionCtx, bidderRequests, bidAdjustmentFactors, conversions, r.Account.DebugAllow)
adapterBids, adapterExtra, anyBidsReturned := e.getAllBids(auctionCtx, bidderRequests, bidAdjustmentFactors, conversions, r.Account.DebugAllow, r.SecGPCFlag)
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a good approach to me. We might refactor this in the future since getAllBids already has a lot of arguments, but I don't see a cleaner way to do this now.


var auc *auction
var cacheErrs []error
Expand Down Expand Up @@ -370,7 +371,7 @@ func (e *exchange) getAllBids(
bidderRequests []BidderRequest,
bidAdjustments map[string]float64,
conversions currency.Conversions,
accountDebugAllowed bool) (
accountDebugAllowed bool, secGPCFlag string) (
map[openrtb_ext.BidderName]*pbsOrtbSeatBid,
map[openrtb_ext.BidderName]*seatResponseExtra, bool) {
// Set up pointers to the bid results
Expand Down Expand Up @@ -401,6 +402,7 @@ func (e *exchange) getAllBids(
}
var reqInfo adapters.ExtraRequestInfo
reqInfo.PbsEntryPoint = bidderRequest.BidderLabels.RType
reqInfo.SecGPCFlag = secGPCFlag
bids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest.BidRequest, bidderRequest.BidderName, adjustmentFactor, conversions, &reqInfo, accountDebugAllowed)

// Add in time reporting
Expand Down