Skip to content

Commit

Permalink
Add Permissions-Policy header with strict settings
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Oct 28, 2022
1 parent 219f06a commit e77a2cd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
25 changes: 25 additions & 0 deletions apps/guide/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django_permissions_policy.PermissionsPolicyMiddleware",
# Whitenoise middleware is used to server static files (CSS, JS, etc.).
# According to the official documentation it should be listed underneath
# SecurityMiddleware.
Expand Down Expand Up @@ -182,6 +183,30 @@
]


# Security

# Configure the `Permissions-Policy` header
# https://github.com/adamchainz/django-permissions-policy
PERMISSIONS_POLICY = {
"accelerometer": [],
"ambient-light-sensor": [],
"autoplay": [],
"camera": [],
"display-capture": [],
"document-domain": [],
"encrypted-media": [],
"fullscreen": [],
"geolocation": [],
"gyroscope": [],
"interest-cohort": [],
"magnetometer": [],
"microphone": [],
"midi": [],
"payment": [],
"usb": [],
}


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

Expand Down
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ django-storages = "1.13.1"
whitenoise = "6.2.0"
psycopg2 = "2.9.3"
wagtail-localize = "^1.3.1"
django-permissions-policy = "^4.13.0"

[tool.poetry.group.dev.dependencies]
black = "^22.10.0"
Expand Down

0 comments on commit e77a2cd

Please sign in to comment.