[Django] #33803: Add crossorigin attribute to django admin templates

5 views
Skip to first unread message

Django

unread,
Jun 23, 2022, 1:17:35 PM6/23/22
to django-...@googlegroups.com
#33803: Add crossorigin attribute to django admin templates
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
fcrozatier |
Type: Bug | Status: new
Component: | Version: 4.0
contrib.admin |
Severity: Normal | Keywords: crossorigin COEP
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When we store our static files on a cloud (digitalocean Spaces in my case)
and we have Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy
headers on the loadbalancer the files are blocked since they are not same-
origin. This is usually not a problem we just have to add a crossorigin
attribute, but in the case of django admin files the templates do not set
them.

Should we add the ''crossorigin'' attribute to the **script**, **link**
and **img** tags of the template files ?

Without this attribute the files are blocked with Cross-Origin Opener
Policy.

--
Ticket URL: <https://code.djangoproject.com/ticket/33803>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 24, 2022, 3:14:35 AM6/24/22
to django-...@googlegroups.com
#33803: Add crossorigin attribute to django admin templates
----------------------------------+--------------------------------------
Reporter: fcrozatier | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: crossorigin COEP | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* cc: Adam Johnson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/33803#comment:1>

Django

unread,
Jun 24, 2022, 4:10:12 AM6/24/22
to django-...@googlegroups.com
#33803: Add crossorigin attribute to django admin templates
----------------------------------+--------------------------------------
Reporter: fcrozatier | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: invalid

Keywords: crossorigin COEP | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Adam Johnson):

* status: new => closed
* resolution: => invalid


Comment:

No, the answer here is not to change Django. When setting COEP to require-
corp, you have two options to allow cross-origin assets to work. *Either*
you set the `crossorigin` attribute, or the assets are served with a CORP
header declaring cross-origin loading to be allowed. Thus, you should
change your static asset hosting to add this CORP header. I blogged about
these headers here: https://adamj.eu/tech/2021/05/01/how-to-set-coep-coop-
corp-security-headers-in-django/

Also with HTTP 2+ it's more efficient to serve your assets from the same
domain, as they can be served on a single connection. Most sites should be
doing this. Whitenoise is a popular solution for doing so with minimal
configuration: https://whitenoise.evans.io/en/stable/ .

--
Ticket URL: <https://code.djangoproject.com/ticket/33803#comment:2>

Django

unread,
Jun 28, 2022, 3:47:17 AM6/28/22
to django-...@googlegroups.com
#33803: Add crossorigin attribute to django admin templates
----------------------------------+--------------------------------------
Reporter: fcrozatier | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: invalid
Keywords: crossorigin COEP | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by fcrozatier):

Replying to [comment:2 Adam Johnson]:
Thank you.

> No, the answer here is not to change Django. When setting COEP to

require-corp, you have two options to allow cross-origin assets to work.


*Either* you set the `crossorigin` attribute, or the assets are served
with a CORP header declaring cross-origin loading to be allowed. Thus, you
should change your static asset hosting to add this CORP header. I blogged

about these headers here: https://adamj.eu/tech/2021/05/01/how-to-set-


coep-coop-corp-security-headers-in-django/
>
> Also with HTTP 2+ it's more efficient to serve your assets from the same
domain, as they can be served on a single connection. Most sites should be
doing this. Whitenoise is a popular solution for doing so with minimal
configuration: https://whitenoise.evans.io/en/stable/ .

--
Ticket URL: <https://code.djangoproject.com/ticket/33803#comment:3>

Reply all
Reply to author
Forward
0 new messages