Private
Public Access
Adds an admin-only dashboard (apps/core) surfacing feeds that are failing to fetch, with error messages, subscriber counts, and a one-click retry that resets backoff and re-queues the fetch. Hardens config/settings/prod.py with the remaining standard Django security settings (HSTS preload, nosniff, referrer-policy, frame-options, SameSite cookies) plus a Content-Security-Policy header via django-csp, as a second layer behind nh3's HTML sanitization of feed content. Adds docs/install.md (pip + gunicorn + systemd + nginx, SQLite and Postgres both covered) plus the systemd units and nginx snippet it references, LICENSE (AGPL-3.0-or-later, matching pyproject.toml), and an updated README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from .base import * # noqa: F403
|
|
from .base import env
|
|
|
|
DEBUG = False
|
|
|
|
# nginx terminates TLS and proxies to gunicorn over a Unix socket (see
|
|
# docs/install.md) — this tells Django's request.is_secure() to trust the
|
|
# header nginx sets, and the redirect/cookie/HSTS settings below assume it.
|
|
SECURE_SSL_REDIRECT = env.bool("SECURE_SSL_REDIRECT", default=True)
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
|
|
|
SESSION_COOKIE_SECURE = True
|
|
CSRF_COOKIE_SECURE = True
|
|
SESSION_COOKIE_SAMESITE = "Lax"
|
|
CSRF_COOKIE_SAMESITE = "Lax"
|
|
|
|
SECURE_HSTS_SECONDS = env.int("SECURE_HSTS_SECONDS", default=60 * 60 * 24 * 7)
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
SECURE_HSTS_PRELOAD = True
|
|
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
SECURE_REFERRER_POLICY = "same-origin"
|
|
X_FRAME_OPTIONS = "DENY"
|
|
|
|
INSTALLED_APPS = [*INSTALLED_APPS, "csp"] # noqa: F405
|
|
MIDDLEWARE = ["csp.middleware.CSPMiddleware", *MIDDLEWARE] # noqa: F405
|
|
|
|
# nh3 already strips <script>/<style>/on* attrs/<iframe> from stored article
|
|
# HTML at ingest (see apps.feeds.services.fetcher.sanitize_html); this is a
|
|
# second, independent layer against any sanitizer gap, and against any
|
|
# future template that forgets to escape feed-supplied text. Remote article
|
|
# images are rendered directly (not proxied, see the PWA offline-caching
|
|
# limitation in the plan), so img-src has to allow any https host.
|
|
CONTENT_SECURITY_POLICY = {
|
|
"DIRECTIVES": {
|
|
"default-src": ["'self'"],
|
|
"img-src": ["'self'", "https:", "data:"],
|
|
"style-src": ["'self'"],
|
|
"script-src": ["'self'"],
|
|
"frame-ancestors": ["'none'"],
|
|
"base-uri": ["'self'"],
|
|
"form-action": ["'self'"],
|
|
}
|
|
}
|