Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into rubicon/do-not-copy…
Browse files Browse the repository at this point in the history
…-certain-fpd-fields

# Conflicts:
#	adapters/rubicon/rubicontest/exemplary/25-26-transition-period.json
#	adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json
#	adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json
#	adapters/rubicon/rubicontest/exemplary/flexible-schema.json
#	adapters/rubicon/rubicontest/exemplary/hardcode-secure.json
#	adapters/rubicon/rubicontest/exemplary/non-bidonmultiformat.json
#	adapters/rubicon/rubicontest/exemplary/simple-banner.json
#	adapters/rubicon/rubicontest/exemplary/simple-native.json
#	adapters/rubicon/rubicontest/exemplary/simple-video.json
#	adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json
#	adapters/rubicon/rubicontest/exemplary/user-fpd.json
#	adapters/rubicon/rubicontest/supplemental/no-site-content-data.json
#	adapters/rubicon/rubicontest/supplemental/no-site-content.json
  • Loading branch information
ddubyk committed Oct 15, 2024
2 parents 8c4f33e + 87d4412 commit 5af0187
Show file tree
Hide file tree
Showing 129 changed files with 7,923 additions and 309 deletions.
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ WORKDIR /app/prebid-server/
ENV GOROOT=/usr/local/go
ENV PATH=$GOROOT/bin:$PATH
ENV GOPROXY="https://proxy.golang.org"

# Installing gcc as cgo uses it to build native code of some modules
RUN apt-get update && \
apt-get install -y git && \
apt-get install -y git gcc && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV CGO_ENABLED 0

# CGO must be enabled because some modules depend on native C code
ENV CGO_ENABLED 1
COPY ./ ./
RUN go mod tidy
RUN go mod vendor
Expand All @@ -30,8 +34,10 @@ RUN chmod a+xr prebid-server
COPY static static/
COPY stored_requests/data stored_requests/data
RUN chmod -R a+r static/ stored_requests/data

# Installing libatomic1 as it is a runtime dependency for some modules
RUN apt-get update && \
apt-get install -y ca-certificates mtr && \
apt-get install -y ca-certificates mtr libatomic1 && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN adduser prebid_user
USER prebid_user
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ or compile a standalone binary using the command:
``` bash
go build .
```
**Note:** if building from source there are a couple dependencies to be aware of:
1. *Compile-time*. Some modules ship native code that requires `cgo` (comes with the `go` compiler) being enabled - by default it is and environment variable `CGO_ENABLED=1` do NOT set it to `0`.
2. *Compile-time*. `cgo` depends on the C-compiler, which usually is `gcc`, but can be changed by setting the value of `CC` env var, f.e. `CC=clang`. On ubuntu `gcc` can be installed via `sudo apt-get install gcc`.
3. *Runtime*. Some modules require `libatomic`. On ubuntu it is installed by running `sudo apt-get install libatomic1`. `libatomic1` is a dependency of `gcc`, so if you are building with `gcc` and running on the same machine, it is likely that `libatomic1` is already installed.

Ensure that you deploy the `/static` directory, as Prebid Server requires those files at startup.

## Developing
Expand Down
48 changes: 48 additions & 0 deletions adapters/adnuntius/adnuntius.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type siteExt struct {
Data interface{} `json:"data"`
}

type adnAdvertiser struct {
LegalName string `json:"legalName,omitempty"`
Name string `json:"name,omitempty"`
}

type Ad struct {
Bid struct {
Amount float64
Expand All @@ -56,6 +61,7 @@ type Ad struct {
LineItemId string
Html string
DestinationUrls map[string]string
Advertiser adnAdvertiser `json:"advertiser,omitempty"`
}

type AdUnit struct {
Expand Down Expand Up @@ -369,6 +375,40 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) {
return gdpr, consent, nil
}

func generateReturnExt(ad Ad, request *openrtb2.BidRequest) (json.RawMessage, error) {
// We always force the publisher to render
var adRender int8 = 0

var requestRegsExt *openrtb_ext.ExtRegs
if request.Regs != nil && request.Regs.Ext != nil {
if err := json.Unmarshal(request.Regs.Ext, &requestRegsExt); err != nil {

return nil, fmt.Errorf("Failed to parse Ext information in Adnuntius: %v", err)
}
}

if ad.Advertiser.Name != "" && requestRegsExt != nil && requestRegsExt.DSA != nil {
legalName := ad.Advertiser.Name
if ad.Advertiser.LegalName != "" {
legalName = ad.Advertiser.LegalName
}
ext := &openrtb_ext.ExtBid{
DSA: &openrtb_ext.ExtBidDSA{
AdRender: &adRender,
Paid: legalName,
Behalf: legalName,
},
}
returnExt, err := json.Marshal(ext)
if err != nil {
return nil, fmt.Errorf("Failed to parse Ext information in Adnuntius: %v", err)
}

return returnExt, nil
}
return nil, nil
}

func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.BidRequest) (*openrtb2.Bid, []error) {

creativeWidth, widthErr := strconv.ParseInt(ad.CreativeWidth, 10, 64)
Expand Down Expand Up @@ -410,6 +450,13 @@ func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.
}
}

extJson, err := generateReturnExt(ad, request)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error extracting Ext: %s", err.Error()),
}}
}

adDomain := []string{}
for _, url := range ad.DestinationUrls {
domainArray := strings.Split(url, "/")
Expand All @@ -429,6 +476,7 @@ func generateAdResponse(ad Ad, imp openrtb2.Imp, html string, request *openrtb2.
Price: price * 1000,
AdM: html,
ADomain: adDomain,
Ext: extJson,
}
return &bid, nil

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"mockBidRequest": {
"id": "test-request-id",
"user": {
"id": "1kjh3429kjh295jkl"
},
"site": {
"ext":{
"data" : {
"key": ["value"]
}
}
},
"regs": {
"ext": {
"dsa": {
"dsarequired": 3,
"datatopub": 1
}
}
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"auId": "123"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://whatever.url?format=prebid&tzo=0",
"body": {
"adUnits": [
{
"auId": "123",
"targetId": "123-test-imp-id",
"dimensions": [[300,250],[300,600]]
}
],
"kv": {
"key": ["value"]
},
"metaData": {
"usi": "1kjh3429kjh295jkl"
},
"context": "unknown"
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"adUnits": [
{
"auId": "0000000000000123",
"targetId": "123-test-imp-id",
"html": "<ADCODE>",
"responseId": "adn-rsp-900646517",
"ads": [
{
"destinationUrls": {
"url": "http://www.google.com"
},
"bid": {
"amount": 20.0,
"currency": "NOK"
},
"adId": "adn-id-1559784094",
"creativeWidth": "980",
"creativeHeight": "240",
"creativeId": "jn9hpzvlsf8cpdmm",
"lineItemId": "q7y9qm5b0xt9htrv",
"advertiser": {
"name": "Name"
}
}
]
}
]
}
}
}
],
"expectedBidResponses": [
{
"bids": [
{
"bid": {
"id": "adn-id-1559784094",
"impid": "test-imp-id",
"price": 20000,
"adm": "<ADCODE>",
"adid": "adn-id-1559784094",
"adomain": [
"google.com"
],
"cid": "q7y9qm5b0xt9htrv",
"crid": "jn9hpzvlsf8cpdmm",
"w": 980,
"h": 240,
"ext": {
"dsa": {
"paid": "Name",
"behalf": "Name",
"adrender": 0
}
}
},
"type": "banner"

}
],
"currency": "NOK"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"mockBidRequest": {
"id": "test-request-id",
"user": {
"id": "1kjh3429kjh295jkl"
},
"site": {
"ext":{
"data" : {
"key": ["value"]
}
}
},
"regs": {
"ext": {
"dsa": {
"dsarequired": 3,
"datatopub": 1
}
}
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"auId": "123"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://whatever.url?format=prebid&tzo=0",
"body": {
"adUnits": [
{
"auId": "123",
"targetId": "123-test-imp-id",
"dimensions": [[300,250],[300,600]]
}
],
"kv": {
"key": ["value"]
},
"metaData": {
"usi": "1kjh3429kjh295jkl"
},
"context": "unknown"
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"adUnits": [
{
"auId": "0000000000000123",
"targetId": "123-test-imp-id",
"html": "<ADCODE>",
"responseId": "adn-rsp-900646517",
"ads": [
{
"destinationUrls": {
"url": "http://www.google.com"
},
"bid": {
"amount": 20.0,
"currency": "NOK"
},
"adId": "adn-id-1559784094",
"creativeWidth": "980",
"creativeHeight": "240",
"creativeId": "jn9hpzvlsf8cpdmm",
"lineItemId": "q7y9qm5b0xt9htrv",
"advertiser": {
"name": "Name",
"legalName": "LegalName"
}
}
]
}
]
}
}
}
],
"expectedBidResponses": [
{
"bids": [
{
"bid": {
"id": "adn-id-1559784094",
"impid": "test-imp-id",
"price": 20000,
"adm": "<ADCODE>",
"adid": "adn-id-1559784094",
"adomain": [
"google.com"
],
"cid": "q7y9qm5b0xt9htrv",
"crid": "jn9hpzvlsf8cpdmm",
"w": 980,
"h": 240,
"ext": {
"dsa": {
"paid": "LegalName",
"behalf": "LegalName",
"adrender": 0
}
}
},
"type": "banner"

}
],
"currency": "NOK"
}
]
}
Loading

0 comments on commit 5af0187

Please sign in to comment.