aboutsummaryrefslogtreecommitdiff
path: root/contrib/webmentions-ssg.example.cfg
blob: 02b074404f165f116dca124b565f6c17bf999ed3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Example configuration for webmentions-ssg.
#
# This is a Python configuration file (not INI). Change example.com, paths, the
# secret key, and SMTP settings before deploying.
#
# Default location in production: /etc/webmentions-ssg.cfg

import logging

# ---------------------------------------------------------------------------
# Flask / Application
# ---------------------------------------------------------------------------
DEBUG = False
BOOTSTRAP_SERVE_LOCAL = True
# BOOTSTRAP_BOOTSWATCH_THEME = "Materia"

# ---------------------------------------------------------------------------
# Flask / Security
# ---------------------------------------------------------------------------
# Generate a persistent random key, e.g.:
# python -c 'import secrets; print(secrets.token_urlsafe(32))'
# Never commit your real key or SMTP password to version control.
SECRET_KEY = "REPLACE_WITH_A_LONG_RANDOM_SECRET"

# ---------------------------------------------------------------------------
# Database and logging
# ---------------------------------------------------------------------------
# SQLite with an absolute file path (four slashes after sqlite:).
# Ensure the service user can write to this directory.
SQLALCHEMY_DATABASE_URI = "sqlite:////var/lib/webmentions-ssg/webmentions-ssg.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False

# Ensure the service user can write to the log file / directory.
LOG_FILE = "/var/log/webmentions-ssg.log"
LOG_LEVEL = logging.INFO
LOG_FORMAT = "[%(asctime)s]:%(levelname)s:%(name)s %(message)s"
LOGFILE_MAX_BYTES = 20_000_000
LOGFILE_BACKUP_COUNT = 10

# ---------------------------------------------------------------------------
# Receiving Webmentions
# ---------------------------------------------------------------------------
# Required: exact hostnames permitted in the 'target' field of an incoming
# Webmention. Include each hostname you serve; wildcards are not supported.
ALLOWED_HOSTNAMES = {"example.com", "www.example.com"}

# Defense in depth: restrict the Huey worker service account with outbound
# firewall/network-policy rules that block loopback, RFC1918, link-local, ULA,
# and cloud metadata ranges, including IPv6. The application also pins
# validated DNS IPs, but deployment-level filtering is still necessary.

# Limits for fetching/verifying incoming sources.
REQUEST_TIMEOUT = 5.0         # seconds per socket operation (both directions)
REQUEST_TOTAL_TIMEOUT = 30.0  # seconds overall, including DNS, redirects and body
MAX_REDIRECTS = 20            # also used for outgoing requests
MAX_SOURCE_BYTES = 1_000_000
# Requeue stuck verifications and lost queued tasks after 15 minutes.
VERIFICATION_TIMEOUT_SECONDS = 900
# Huey cron expression: every five minutes (in UTC).
VERIFICATION_REAPER_SCHEDULE = "*/5 * * * *"

# ---------------------------------------------------------------------------
# Rate limiting
# ---------------------------------------------------------------------------
# In-memory storage is for development/testing ONLY. Production requires shared
# storage, such as Redis, or the application will refuse to start.
RATELIMIT_STORAGE_URI = "memory://"
RATELIMIT_HEADERS_ENABLED = True

# Limits per client and across all clients for incoming Webmention submissions.
ENDPOINT_RATE_LIMIT = "10/minute;100/hour"
ENDPOINT_GLOBAL_RATE_LIMIT = "1000/hour"
# Minimum seconds between verifications of the same source/target pair.
ENDPOINT_REVERIFY_COOLDOWN_SECONDS = 600

# Limit login POST attempts per client.
LOGIN_RATE_LIMIT = "5/minute;30/hour"

# ---------------------------------------------------------------------------
# Sending Webmentions from a statically generated site
# ---------------------------------------------------------------------------
# Folder containing generated pages named index.html. Set to None to disable
# scanning. Its root-level index.html is not scanned.
SOURCE_DIRECTORY = "/var/www/example.com/public"

# Needed for pages without absolute canonical URLs.
SOURCE_BASE_URL = "https://example.com/"

# Huey cron expression: minute hour day-of-month month day-of-week.
SCANNER_SCHEDULE = "0 * * * *"    # every hour

# Temporary delivery failures use persisted exponential backoff: 1, 2, 4,
# 8, then 16 hours between attempts with these defaults. After six total
# attempts for a revision, the failure becomes terminal. A changed source or
# explicit manual resend starts a fresh retry budget.
SEND_MAX_ATTEMPTS = 6
SEND_RETRY_BASE_SECONDS = 3600
SEND_RETRY_MAX_SECONDS = 86400

# Do not send Webmentions to your own site. Glob patterns are supported here.
IGNORED_HOSTNAMES = ("example.com", "*.example.com")
MAX_TARGET_BYTES = 1_000_000

# ---------------------------------------------------------------------------
# Background tasks (Huey)
# ---------------------------------------------------------------------------
# Use a shared, persistent backend for production app and worker processes.
# Redis must be running and reachable by both.
HUEY_URL = "redis://127.0.0.1:6379/0"

# ---------------------------------------------------------------------------
# Email notifications for newly verified received Webmentions
# ---------------------------------------------------------------------------
# Set NOTIFICATION_EMAIL = None to disable notification emails.
NOTIFICATION_EMAIL = "admin@example.com"
# Daily notification digest at 08:00 UTC (Huey defaults to UTC).
NOTIFICATION_SCHEDULE = "0 8 * * *"

# Example SMTP-over-STARTTLS setup; adapt to your mail provider.
MAIL_SERVER = "smtp.example.com"
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USE_SSL = False
MAIL_USERNAME = "webmentions@example.com"
MAIL_PASSWORD = "REPLACE_WITH_SMTP_PASSWORD"
MAIL_DEFAULT_SENDER = "webmentions@example.com"