GithubHelp home page GithubHelp logo

go-gdpr's Introduction

Build Status ReportCard GoDoc

Go Support for GDPR

This project includes Go APIs for working with the IAB's GDPR Transparency & Consent Framework.

Usage

Consent String Parsing

package main

import (
  "log"

  "github.com/prebid/go-gdpr/consentconstants"
  "github.com/prebid/go-gdpr/vendorconsent"
)

func DemoConsentStringParsing() {
	encodedString := "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw"
	data, _ := base64.RawURLEncoding.DecodeString(encodedString)

	consent, err := vendorconsent.Parse(data)
	if err != nil {
		log.Printf("Data was not a valid consent string: %v", err)
		return
	}

	log.Printf("There are %d vendors in this consent string.", consent.MaxVendorID())
	log.Printf("This consent string refers to version %d of the Global Vendor List.", consent.VendorListVersion())
	log.Printf("Vendor %d has the user's consent? %t", 3, consent.VendorConsent(3))
}

Vendor List Parsing

package main

import (
  "io/ioutil"
  "log"
  "net/http"

  "github.com/prebid/go-gdpr/consentconstants"
  "github.com/prebid/go-gdpr/vendorlist"
)

func DemoVendorListParsing() {
  resp, _ := http.Get("https://vendorlist.consensu.org/vendorlist.json")
  data, _ := ioutil.ReadAll(resp.Body)

  vendors := vendorlist.ParseLazily(data)
  log.Printf("The Vendor List Version is %d.", vendors.Version())

  vendor := vendors.Vendor(3)
  if vendor == nil {
    log.Print("Vendor 3 did not exist in the list.")
  } else {
    log.Printf("Vendor 3 claimed a legitimate interest for ad selection, delivery, and reporting? %t", vendor.LegitimateInterest(consentconstants.AdSelectionDeliveryReporting))
    log.Printf("Did Vendor 3 claim to store or retrieve info? %t", vendor.Purpose(consentconstants.InfoStorageAccess))
  }
}

Contributing

Pull Requests are always welcome for:

  1. Regression tests which demonstrate bugs
  2. Bugfixes which make regression tests pass
  3. Documentation improvements
  4. Improved error messages
  5. Support for parsing other fields of the Vendor Consent String. The only ones implemented now are ones which we needed.
  6. Support for other IAB-related GDPR standards, such as the Publisher Purposes Consent String
  7. Benchmarks
  8. Optimizations which don't break the unit tests and prove to be faster through the benchmarks.

Other pull requests may also be accepted, but larger features should probably be discussed in an Issue first.

go-gdpr's People

Contributors

dbemiller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.