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

Ads.Cert Call Sign support #2241

Merged
merged 46 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1312664
Initial preparation for Ads.Cert Call Sign support
May 6, 2022
1722b81
First initial working version
May 10, 2022
384bb22
Added request option and bidder config to enable or disable ads certs
May 23, 2022
a94d723
Code clean up and README file added
May 24, 2022
1547a0b
Code refactoring and clean up
May 25, 2022
7f91db7
Unit tests fix
May 25, 2022
3e6f780
Merge branch 'master' into ads_cert
May 25, 2022
82715a9
Merge fixes
May 25, 2022
9c28dd6
Code refactoring and clean up
May 26, 2022
0bc246d
Added more go docs for newly defines structures
May 26, 2022
aea4f71
Added unit tests
May 26, 2022
9bffd99
Added unit tests
May 26, 2022
b8baa68
Added unit tests
May 27, 2022
ac47bd5
Minor clean up
May 28, 2022
c78b16d
Added remote signer.
May 29, 2022
540c9f8
Removed optional code
Jun 1, 2022
26dac9b
Added tests for NewAdCertsSigner
Jun 1, 2022
de1d8fa
Unit tests for remote signer
Jun 2, 2022
4b9e937
CR fixes part I
Jun 2, 2022
7b6ffe9
CR fixes part II
Jun 3, 2022
8991f4e
Code clean up
Jun 8, 2022
6257437
Merge branch 'master' into ads_cert
Jun 8, 2022
6f87497
Merge fixes
Jun 8, 2022
a091df9
Merge branch 'master' into ads_cert
Jun 22, 2022
1e012b0
renamed "in-process" to "inprocess" to avoid env variables conflict
Jun 23, 2022
8b3a795
Renamed adscert to adsCert
Jun 23, 2022
4462439
Code refactoring
Jun 23, 2022
8b0617b
Code refactoring and signers config validation
Jun 24, 2022
f0ac967
Code refactoring
Jun 24, 2022
bb4c9d9
Code refactoring
Jun 24, 2022
cea7973
Merge branch 'master' into ads_cert
Jun 30, 2022
1636dd3
Resolved merge errors
Jun 30, 2022
2d29975
Merge branch 'master' into ads_cert
Jul 5, 2022
37d2529
Merge with master
Jul 5, 2022
2178fc6
Code review comments
Jul 8, 2022
8709b76
Merge branch 'master' into ads_cert
Jul 11, 2022
72cae9b
Merge conflict fix
Jul 11, 2022
7486973
Moved validation to config.go
Jul 11, 2022
a1177a9
Minor fixes
Jul 13, 2022
d3d50bb
Modified config from experiment.adscert.enabled to experiment.adscert…
Jul 13, 2022
a92f723
Merge branch 'master' into ads_cert
Jul 18, 2022
999e6da
Code review fixes
Jul 19, 2022
d0a9966
Code review fixes
Jul 19, 2022
b9fc196
Code review fixes
Jul 20, 2022
5b81715
Code cleanup
Jul 27, 2022
c3c0fc2
Code cleanup
Jul 27, 2022
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
Added request option and bidder config to enable or disable ads certs
  • Loading branch information
vsolovei committed May 23, 2022
commit 384bb22559a6fa7b0592c14a88039c4e8c69d7e2
1 change: 1 addition & 0 deletions config/bidderinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type BidderInfo struct {
Debug *DebugInfo `yaml:"debug"`
GVLVendorID uint16 `yaml:"gvlVendorID"`
Syncer *Syncer `yaml:"userSync"`
AdsCertDisable bool `yaml:"adsCertDisable"` //default false
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
}

// MaintainerInfo specifies the support email address for a bidder.
Expand Down
6 changes: 3 additions & 3 deletions exchange/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type adaptedBidder interface {
//
// Any errors will be user-facing in the API.
// Error messages should help publishers understand what might account for "bad" bids.
requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (*pbsOrtbSeatBid, []error)
requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (*pbsOrtbSeatBid, []error)
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
}

const ImpIdReqBody = "Stored bid response for impression id: "
Expand Down Expand Up @@ -135,7 +135,7 @@ type bidderAdapterConfig struct {
DebugInfo config.DebugInfo
}

func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (*pbsOrtbSeatBid, []error) {
func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (*pbsOrtbSeatBid, []error) {

var reqData []*adapters.RequestData
var errs []error
Expand Down Expand Up @@ -165,7 +165,7 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest Bidde
if reqInfo.GlobalPrivacyControlHeader == "1" {
reqData[i].Headers.Add("Sec-GPC", reqInfo.GlobalPrivacyControlHeader)
}
if adCertSigner != nil {
if adCertSigner != nil && addCallSignHeader {
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
signatureMessage, err := adCertSigner.Sign(reqData[i].Uri, reqData[i].Body)
if err == nil {
reqData[i].Headers.Add(adscert.SignHeader, signatureMessage)
Expand Down
4 changes: 2 additions & 2 deletions exchange/bidder_validate_bids.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type validatedBidder struct {
bidder adaptedBidder
}

func (v *validatedBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (*pbsOrtbSeatBid, []error) {
seatBid, errs := v.bidder.requestBid(ctx, bidderRequest, bidAdjustment, conversions, reqInfo, accountDebugAllowed, headerDebugAllowed, adCertSigner)
func (v *validatedBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (*pbsOrtbSeatBid, []error) {
seatBid, errs := v.bidder.requestBid(ctx, bidderRequest, bidAdjustment, conversions, reqInfo, accountDebugAllowed, headerDebugAllowed, adCertSigner, addCallSignHeader)
if validationErrors := removeInvalidBids(bidderRequest.BidRequest, seatBid); len(validationErrors) > 0 {
errs = append(errs, validationErrors...)
}
Expand Down
10 changes: 5 additions & 5 deletions exchange/bidder_validate_bids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestAllValidBids(t *testing.T) {
BidRequest: &openrtb2.BidRequest{},
BidderName: openrtb_ext.BidderAppnexus,
}
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil)
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil, false)
assert.Len(t, seatBid.bids, 4)
assert.Len(t, errs, 0)
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestAllBadBids(t *testing.T) {
BidRequest: &openrtb2.BidRequest{},
BidderName: openrtb_ext.BidderAppnexus,
}
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil)
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil, false)
assert.Len(t, seatBid.bids, 0)
assert.Len(t, errs, 7)
}
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestMixedBids(t *testing.T) {
BidRequest: &openrtb2.BidRequest{},
BidderName: openrtb_ext.BidderAppnexus,
}
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil)
seatBid, errs := bidder.requestBid(context.Background(), bidderReq, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil, false)
assert.Len(t, seatBid.bids, 3)
assert.Len(t, errs, 5)
}
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestCurrencyBids(t *testing.T) {
}
bidderRequest := BidderRequest{BidRequest: request, BidderName: openrtb_ext.BidderAppnexus}

seatBid, errs := bidder.requestBid(context.Background(), bidderRequest, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil)
seatBid, errs := bidder.requestBid(context.Background(), bidderRequest, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false, nil, false)
assert.Len(t, seatBid.bids, expectedValidBids)
assert.Len(t, errs, expectedErrs)
}
Expand All @@ -323,6 +323,6 @@ type mockAdaptedBidder struct {
errorResponse []error
}

func (b *mockAdaptedBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (*pbsOrtbSeatBid, []error) {
func (b *mockAdaptedBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (*pbsOrtbSeatBid, []error) {
return b.bidResponse, b.errorResponse
}
10 changes: 7 additions & 3 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog *
} else {
// List of bidders we have requests for.
liveAdapters = listBiddersWithRequests(bidderRequests)
adapterBids, adapterExtra, anyBidsReturned = e.getAllBids(auctionCtx, bidderRequests, bidAdjustmentFactors, conversions, accountDebugAllow, r.GlobalPrivacyControlHeader, debugLog.DebugOverride)
adapterBids, adapterExtra, anyBidsReturned = e.getAllBids(auctionCtx, bidderRequests, bidAdjustmentFactors, conversions, accountDebugAllow, r.GlobalPrivacyControlHeader, debugLog.DebugOverride, requestExt.Prebid.Experiment)
}

var auc *auction
Expand Down Expand Up @@ -485,7 +485,8 @@ func (e *exchange) getAllBids(
conversions currency.Conversions,
accountDebugAllowed bool,
globalPrivacyControlHeader string,
headerDebugAllowed bool) (
headerDebugAllowed bool,
experiment *openrtb_ext.Experiment) (
map[openrtb_ext.BidderName]*pbsOrtbSeatBid,
map[openrtb_ext.BidderName]*seatResponseExtra, bool) {
// Set up pointers to the bid results
Expand Down Expand Up @@ -518,7 +519,10 @@ func (e *exchange) getAllBids(
reqInfo.PbsEntryPoint = bidderRequest.BidderLabels.RType
reqInfo.GlobalPrivacyControlHeader = globalPrivacyControlHeader

bids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest, adjustmentFactor, conversions, &reqInfo, accountDebugAllowed, headerDebugAllowed, e.adCertSigner)
//add call sign header for bidders where AdsCertDisable is not disables and request.ext.prebid.experiment.adscert.enabled is set to true
addCallSignHeader := experiment != nil && experiment.AdsCert != nil && experiment.AdsCert.Enabled && !e.bidderInfo[string(bidderRequest.BidderName)].AdsCertDisable

bids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest, adjustmentFactor, conversions, &reqInfo, accountDebugAllowed, headerDebugAllowed, e.adCertSigner, addCallSignHeader)

// Add in time reporting
elapsed := time.Since(start)
Expand Down
6 changes: 3 additions & 3 deletions exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4038,7 +4038,7 @@ type validatingBidder struct {
mockResponses map[string]bidderResponse
}

func (b *validatingBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (seatBid *pbsOrtbSeatBid, errs []error) {
func (b *validatingBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (seatBid *pbsOrtbSeatBid, errs []error) {
if expectedRequest, ok := b.expectations[string(bidderRequest.BidderName)]; ok {
if expectedRequest != nil {
if expectedRequest.BidAdjustment != bidAdjustment {
Expand Down Expand Up @@ -4086,7 +4086,7 @@ type capturingRequestBidder struct {
req *openrtb2.BidRequest
}

func (b *capturingRequestBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (seatBid *pbsOrtbSeatBid, errs []error) {
func (b *capturingRequestBidder) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (seatBid *pbsOrtbSeatBid, errs []error) {
b.req = bidderRequest.BidRequest
return &pbsOrtbSeatBid{}, nil
}
Expand Down Expand Up @@ -4188,7 +4188,7 @@ func (e *emptyUsersync) HasAnyLiveSyncs() bool {

type panicingAdapter struct{}

func (panicingAdapter) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer) (posb *pbsOrtbSeatBid, errs []error) {
func (panicingAdapter) requestBid(ctx context.Context, bidderRequest BidderRequest, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed, headerDebugAllowed bool, adCertSigner adscert.Signer, addCallSignHeader bool) (posb *pbsOrtbSeatBid, errs []error) {
panic("Panic! Panic! The world is ending!")
}

Expand Down
9 changes: 9 additions & 0 deletions openrtb_ext/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ type ExtRequestPrebid struct {

CurrencyConversions *ExtRequestCurrency `json:"currency,omitempty"`
BidderConfigs []BidderConfig `json:"bidderconfig,omitempty"`
Experiment *Experiment `json:"experiment,omitempty"`
}

type Experiment struct {
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
AdsCert *AdsCert `json:"adscert,omitempty"`
}

type AdsCert struct {
Enabled bool `json:"enabled,omitempty"`
}

type BidderConfig struct {
Expand Down