Skip to content

Commit 83bd827

Browse files
authored
Add X-Content-Type-Options as a custom domain header (#10062)
* Add X-Content-Type-Options as a custom domain header A user requested this via https://infosec.mozilla.org/guidelines/web_security * Add migration
1 parent 7afc60a commit 83bd827

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

dockerfiles/nginx/proxito.conf.template

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ server {
8282
add_header Access-Control-Allow-Headers $access_control_allow_headers always;
8383
set $x_frame_options $upstream_http_x_frame_options;
8484
add_header X-Frame-Options $x_frame_options always;
85+
set $x_content_type_options $upstream_http_x_content_type_options;
86+
add_header X-Content-Type-Options $x_content_type_options always;
8587
# Minio sets this header on the response, and we don't want to copy it to the response
8688
proxy_hide_header Content-Security-Policy;
8789
set $content_security_policy $upstream_http_content_security_policy;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 3.2.18 on 2023-02-22 19:33
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("projects", "0095_default_branch_helptext"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="httpheader",
15+
name="name",
16+
field=models.CharField(
17+
choices=[
18+
("access_control_allow_origin", "Access-Control-Allow-Origin"),
19+
("access_control_allow_headers", "Access-Control-Allow-Headers"),
20+
("content_security_policy", "Content-Security-Policy"),
21+
("feature_policy", "Feature-Policy"),
22+
("permissions_policy", "Permissions-Policy"),
23+
("referrer_policy", "Referrer-Policy"),
24+
("x_frame_options", "X-Frame-Options"),
25+
("x_content_type_options", "X-Content-Type-Options"),
26+
],
27+
max_length=128,
28+
),
29+
),
30+
]

readthedocs/projects/models.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1774,13 +1774,14 @@ class HTTPHeader(TimeStampedModel, models.Model):
17741774
"""
17751775

17761776
HEADERS_CHOICES = (
1777-
('access_control_allow_origin', 'Access-Control-Allow-Origin'),
1778-
('access_control_allow_headers', 'Access-Control-Allow-Headers'),
1779-
('content_security_policy', 'Content-Security-Policy'),
1780-
('feature_policy', 'Feature-Policy'),
1781-
('permissions_policy', 'Permissions-Policy'),
1782-
('referrer_policy', 'Referrer-Policy'),
1783-
('x_frame_options', 'X-Frame-Options'),
1777+
("access_control_allow_origin", "Access-Control-Allow-Origin"),
1778+
("access_control_allow_headers", "Access-Control-Allow-Headers"),
1779+
("content_security_policy", "Content-Security-Policy"),
1780+
("feature_policy", "Feature-Policy"),
1781+
("permissions_policy", "Permissions-Policy"),
1782+
("referrer_policy", "Referrer-Policy"),
1783+
("x_frame_options", "X-Frame-Options"),
1784+
("x_content_type_options", "X-Content-Type-Options"),
17841785
)
17851786

17861787
domain = models.ForeignKey(

0 commit comments

Comments
 (0)