Skip to content

Commit

Permalink
Merge pull request #11 from nhymxu/6-upgrade-to-support-new-googles-t…
Browse files Browse the repository at this point in the history
…opics-api

replace FLoC with Topics API
  • Loading branch information
nhymxu authored Dec 25, 2024
2 parents 048c743 + 33cc7fa commit 40b959f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Django middleware to disable Google's Federated Learning of Cohorts (`FLoC`) tracking

New version is Topics API

## Python / Django Support

- Python 3.8+
Expand All @@ -27,8 +29,11 @@ MIDDLEWARE = (
)
```

This will set the `Permissions-Policy` header to a value of
`interest-cohort=()` for every request served by Django.
This will set the `Permissions-Policy` header to a value of `browsing-topics=()` for every request served by Django.

Reference:
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/browsing-topics
- https://developers.google.com/privacy-sandbox/private-advertising/topics/web/controls#opt_out_as_a_developer

## Support

Expand Down
2 changes: 1 addition & 1 deletion django_floc_disable/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.0"
__version__ = "1.2.0"
2 changes: 1 addition & 1 deletion django_floc_disable/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def __init__(self, get_response):
def __call__(self, request):
response = self.get_response(request)

policy = 'interest-cohort=()'
policy = 'browsing-topics=()'
if response.get('Permissions-Policy', ''):
policy = response['Permissions-Policy'] + ', ' + policy

Expand Down
4 changes: 2 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class MiddlewareTest(TestCase):
def test_not_exists_header(self):
response = self.client.get('/')
self.assertEqual(response['Permissions-Policy'], 'interest-cohort=()')
self.assertEqual(response['Permissions-Policy'], 'browsing-topics=()')

def test_exists_header(self):
response = self.client.get('/test_exists')
self.assertEqual(response['Permissions-Policy'], 'geolocation=*, camera=(), interest-cohort=()')
self.assertEqual(response['Permissions-Policy'], 'geolocation=*, camera=(), browsing-topics=()')

0 comments on commit 40b959f

Please sign in to comment.