mirror of
https://github.com/welpo/tabi.git
synced 2025-10-11 07:46:15 +02:00
⚡️ refactor: co-locate images (#200)
This commit is contained in:
parent
c0a07cb467
commit
8aabeaecc3
173 changed files with 205 additions and 205 deletions
35
content/blog/security/index.md
Normal file
35
content/blog/security/index.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
+++
|
||||
title = "Secure by default"
|
||||
date = 2023-02-22
|
||||
updated = 2023-09-29
|
||||
description = "tabi has an easily customizable Content Security Policy (CSP) with safe defaults. Get peace of mind and an A+ on Mozilla Observatory."
|
||||
|
||||
[taxonomies]
|
||||
tags = ["security", "showcase"]
|
||||
|
||||
[extra]
|
||||
social_media_card = "social_cards/blog_security.jpg"
|
||||
+++
|
||||
|
||||
The default configuration of the theme gets an A+ score on [Mozilla Observatory](https://observatory.mozilla.org).[^1]
|
||||
|
||||
This is accomplished by programatically configuring Content Security Policy (CSP) headers based on a user-defined list of allowed domains in the `config.toml` file. Here's the default and recommended setup (you could remove the last directive if you don't want to embed YouTube videos):
|
||||
|
||||
```toml
|
||||
[extra]
|
||||
allowed_domains = [
|
||||
{ directive = "font-src", domains = ["'self'", "data:"] },
|
||||
{ directive = "img-src", domains = ["'self'", "https://*", "data:"] },
|
||||
{ directive = "script-src", domains = ["'self'"] },
|
||||
{ directive = "style-src", domains = ["'self'"] },
|
||||
{ directive = "frame-src", domains = ["https://www.youtube-nocookie.com"] },
|
||||
]
|
||||
```
|
||||
|
||||
The `allowed_domains` list specifies the URLs that the website should be able to connect to, and each domain in the list is associated with a CSP directive such as `frame-src`, `connect-src`, or `script-src`. The `templates/partials/header.html` file dynamically generates the CSP header based on this list.
|
||||
|
||||
This feature allows you to easily customize the website's security headers to allow for specific use cases, such as embedding YouTube videos, loading scripts or remote fonts ([not recommended](https://www.albertovarela.net/blog/2022/11/stop-using-google-fonts/)).
|
||||
|
||||
**Note**: [enabling comments](@/blog/comments/index.md) or [analytics](@/blog/mastering-tabi-settings/index.md#analytics) automatically allows scripts/frames/styles/connections as needed from the respective services.
|
||||
|
||||
[^1]: Requires proper webserver configuration (e.g. redirecting HTTP traffic to HTTPS).
|
Loading…
Add table
Add a link
Reference in a new issue