mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: add cdn.jsdelivr.net to script/style CSP
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
df0a4a2be2
commit
9faa7b801d
1 changed files with 7 additions and 3 deletions
|
@ -253,10 +253,14 @@ async def add_security_headers(request: Request, call_next: typing.Callable):
|
|||
# Add CSP header.
|
||||
nonce = request.user.nonce
|
||||
csp = "default-src 'self'; "
|
||||
script_hosts = []
|
||||
|
||||
# swagger-ui needs access to cdn.jsdelivr.net javascript
|
||||
script_hosts = ["cdn.jsdelivr.net"]
|
||||
csp += f"script-src 'self' 'nonce-{nonce}' " + " ".join(script_hosts)
|
||||
# It's fine if css is inlined.
|
||||
csp += "; style-src 'self' 'unsafe-inline'"
|
||||
|
||||
# swagger-ui needs access to cdn.jsdelivr.net css
|
||||
css_hosts = ["cdn.jsdelivr.net"]
|
||||
csp += "; style-src 'self' 'unsafe-inline' " + " ".join(css_hosts)
|
||||
response.headers["Content-Security-Policy"] = csp
|
||||
|
||||
# Add XTCO header.
|
||||
|
|
Loading…
Add table
Reference in a new issue