mirror of
https://github.com/truespar/sentio.git
synced 2026-11-17 08:16:11 +00:00
rate_limit_middleware was never wired into the router, and it keyed only on the AuthContext extension - which no middleware ever inserted, since authentication happens in the handler extractor. So nothing was rate limited at all. The router now layers three stages on authenticated routes: an IP-keyed pre-auth limiter (120 req/min per address) that meters token guessing and abuse of public endpoints, then auth middleware that resolves the bearer token once and publishes the context as a request extension (handlers reuse it instead of repeating the DB lookup), and finally the per-tenant limiter reading that context. Health, docs, and tracking endpoints stay outside the auth layer. Client IPs come from the socket peer; when the peer is a configured trusted proxy (SERVER__API_TRUSTED_PROXIES), the X-Forwarded-For origin is used instead. A direct client cannot spoof the header past the limiter.
258 lines
6.5 KiB
TOML
258 lines
6.5 KiB
TOML
[server]
|
|
hostname = "mail.example.com"
|
|
dns_resolver = "google" # Options: system, google, cloudflare_tls, quad9_tls
|
|
# One entry per port. On Linux (net.ipv6.bindv6only=0) a "[::]" bind already
|
|
# accepts IPv4, so listing both 0.0.0.0 and [::] for the same port makes the
|
|
# second bind fail with EADDRINUSE and aborts the remaining listeners.
|
|
listen_smtp = ["0.0.0.0:25"]
|
|
listen_smtps = ["0.0.0.0:465"]
|
|
listen_submission = ["0.0.0.0:587"]
|
|
listen_api = "0.0.0.0:8080"
|
|
workers = 0
|
|
max_connections = 10000
|
|
proxy_protocol = false
|
|
xclient_enabled = false
|
|
xclient_allowed_ips = []
|
|
# IPs allowed to set X-Forwarded-For on API requests (pre-auth rate limiting
|
|
# keys on the forwarded origin for these peers). Leave empty when the API is
|
|
# reached directly; add your load balancer's IP when running behind an L7 proxy.
|
|
api_trusted_proxies = []
|
|
shutdown_drain_secs = 30
|
|
shutdown_force_secs = 60
|
|
max_api_body_size_mb = 50
|
|
# Per-instance secret for HMAC-signing VERP bounce return-path tokens.
|
|
# Generate with `openssl rand -hex 32` and treat as a secret. MUST be set
|
|
# when any tenant has verp_enabled=true - otherwise sentio refuses to start.
|
|
# Rotating this value invalidates all in-flight bounce tokens.
|
|
# verp_secret = "REPLACE_ME_WITH_OPENSSL_RAND_HEX_32"
|
|
|
|
[server.inbound_timeouts]
|
|
greeting_secs = 300
|
|
command_secs = 300
|
|
data_initiation_secs = 120
|
|
data_block_secs = 180
|
|
data_termination_secs = 600
|
|
|
|
[server.inbound_limits]
|
|
max_recipients_per_message = 100
|
|
max_messages_per_session = 50
|
|
max_message_size_mb = 50
|
|
max_received_headers = 50
|
|
max_line_length = 998
|
|
max_auth_attempts = 3
|
|
max_commands_per_session = 1000
|
|
strict_ehlo_validation = false
|
|
|
|
[tls]
|
|
cert_path = "/etc/sentio/cert.pem"
|
|
key_path = "/etc/sentio/key.pem"
|
|
min_version = "1.2"
|
|
sni_enabled = true
|
|
|
|
# SNI: additional certs per domain
|
|
# [[tls.sni_certs]]
|
|
# domains = ["mail.tenant1.com", "mail.tenant2.com"]
|
|
# cert_path = "/etc/sentio/certs/tenant1.pem"
|
|
# key_path = "/etc/sentio/certs/tenant1-key.pem"
|
|
|
|
[tls.acme]
|
|
enabled = false
|
|
email = "admin@example.com"
|
|
directory_url = "https://acme-v02.api.letsencrypt.org/directory"
|
|
domains = ["mail.example.com"]
|
|
storage_path = "/etc/sentio/acme"
|
|
|
|
[database]
|
|
url = "postgres://sentio:sentio@localhost:5432/sentio"
|
|
max_connections = 50
|
|
min_connections = 5
|
|
|
|
[kv]
|
|
# KV backend for rate-limit / ban / warmup / greylist state.
|
|
# "redis" - any RESP-compatible Redis or Valkey server.
|
|
backend = "redis"
|
|
|
|
[redis]
|
|
# Standard redis:// URL. Use rediss:// for TLS.
|
|
url = "redis://127.0.0.1:6379/0"
|
|
|
|
[nats]
|
|
url = "nats://127.0.0.1:4222"
|
|
prefetch_count = 50
|
|
llm_prefetch_count = 1
|
|
publisher_confirms = true
|
|
connection_timeout_secs = 30
|
|
max_retries = 5
|
|
stream_max_age_secs = 86400
|
|
dead_stream_max_age_secs = 2592000
|
|
|
|
[storage]
|
|
# S3-compatible blob store (AWS S3, R2, B2, MinIO, SeaweedFS, Ceph, …).
|
|
# The access/secret pair below is a placeholder - production deployments
|
|
# override via SENTIO__STORAGE__ACCESS_KEY / SENTIO__STORAGE__SECRET_KEY.
|
|
endpoint_url = "http://127.0.0.1:8333"
|
|
access_key = "sentio"
|
|
secret_key = "CHANGE_ME"
|
|
bucket = "sentio-eml"
|
|
path_style = true
|
|
region = "us-east-1"
|
|
store_raw_eml = true
|
|
orphan_cleanup_interval_hours = 6
|
|
orphan_max_age_hours = 24
|
|
|
|
[scanning]
|
|
enabled = true
|
|
clamd_host = "127.0.0.1:3310"
|
|
clamd_timeout_secs = 30
|
|
max_attachment_size_mb = 25
|
|
max_message_size_mb = 50
|
|
|
|
[scanning.per_tenant_defaults]
|
|
scan_inbound = true
|
|
scan_outbound = false
|
|
reject_on_virus = true
|
|
|
|
[abuse]
|
|
max_connections_per_minute = 50
|
|
max_auth_failures_per_hour = 10
|
|
ban_duration_secs = 3600
|
|
reputation_warn_threshold = 5.0
|
|
reputation_greylist_threshold = 7.5
|
|
reputation_reject_threshold = 10.0
|
|
reputation_decay_hours = 24
|
|
reverse_dns_required = false
|
|
dnsbl_lists = ["zen.spamhaus.org", "b.barracudacentral.org", "bl.spamcop.net", "dnsbl.sorbs.net"]
|
|
dnsbl_cache_secs = 3600
|
|
whitelist_ips = []
|
|
whitelist_cidrs = []
|
|
|
|
[abuse.greylist]
|
|
enabled = true
|
|
min_delay_secs = 300
|
|
max_age_hours = 48
|
|
|
|
[spam]
|
|
backend = "rspamd"
|
|
score_reject = 12.0
|
|
score_add_header = 6.0
|
|
score_greylist = 4.0
|
|
score_llm_review_min = 4.0
|
|
score_llm_review_max = 6.0
|
|
|
|
[spam.rspamd]
|
|
url = "http://127.0.0.1:11333"
|
|
timeout_secs = 10
|
|
password = ""
|
|
|
|
[spam.builtin]
|
|
dnsbl_lists = ["zen.spamhaus.org", "b.barracudacentral.org", "bl.spamcop.net", "dnsbl.sorbs.net"]
|
|
uribl_lists = ["multi.uribl.com", "dbl.spamhaus.org"]
|
|
bayes_enabled = true
|
|
heuristics_enabled = true
|
|
|
|
[delivery]
|
|
max_connections = 1000
|
|
max_connections_per_dest = 20
|
|
idle_timeout_secs = 300
|
|
retry_base_secs = 300
|
|
retry_max_secs = 4000
|
|
max_retries = 50
|
|
queue_lifetime_days = 5
|
|
batch_size = 100
|
|
max_schedule_hours = 72
|
|
|
|
# Per-domain retry overrides (uncomment to customize):
|
|
# [delivery.domain_overrides."gmail.com"]
|
|
# retry_base_secs = 600
|
|
# retry_max_secs = 7200
|
|
# max_retries = 30
|
|
#
|
|
# [delivery.domain_overrides."outlook.com"]
|
|
# retry_base_secs = 600
|
|
# retry_max_secs = 7200
|
|
|
|
[delivery.rate_limits]
|
|
default_per_minute = 100
|
|
gmail_per_minute = 50
|
|
microsoft_per_minute = 80
|
|
|
|
[delivery.relay]
|
|
enabled = true
|
|
host = "127.0.0.1"
|
|
port = 2525
|
|
# auth_username = "sentio"
|
|
# auth_password_env = "RELAY_PASSWORD"
|
|
tls_mode = "none"
|
|
|
|
[auth]
|
|
dkim_default_selector = "sentio"
|
|
dkim_algorithm = "ed25519"
|
|
dkim_rsa_key_bits = 2048
|
|
spf_check_inbound = true
|
|
dmarc_check_inbound = true
|
|
arc_sign_forward = true
|
|
mta_sts_cache_secs = 86400
|
|
dane_enabled = true
|
|
bimi_check_inbound = true
|
|
bimi_vmc_required = false
|
|
|
|
[auth.fbl]
|
|
enabled = true
|
|
fbl_address = "fbl@mail.example.com"
|
|
auto_suppress = true
|
|
|
|
[deliverability]
|
|
list_unsubscribe_enabled = true
|
|
batv_enabled = true
|
|
batv_key = ""
|
|
batv_tag_lifetime_days = 7
|
|
required_addresses = ["postmaster", "abuse"]
|
|
dns_check_interval_hours = 6
|
|
|
|
[tracking]
|
|
open_tracking = false
|
|
click_tracking = false
|
|
tracking_domain = ""
|
|
|
|
[webhooks]
|
|
max_retries = 10
|
|
retry_backoff_base_secs = 60
|
|
signing_algorithm = "hmac-sha256"
|
|
delivery_timeout_secs = 30
|
|
max_concurrent_per_endpoint = 10
|
|
max_per_second_per_endpoint = 100
|
|
|
|
[llm]
|
|
# Off by default. Set enabled = true and point at OpenAI, Anthropic, an
|
|
# Ollama instance, or any OpenAI-compatible endpoint to turn on
|
|
# classification. base_url may be left empty for the provider's default.
|
|
enabled = false
|
|
provider = "openai"
|
|
model = "gpt-4o-mini"
|
|
base_url = ""
|
|
api_key_env = "OPENAI_API_KEY"
|
|
temperature = 0.3
|
|
max_input_tokens = 2000
|
|
classify_inbound = true
|
|
classify_outbound = false
|
|
auto_respond = false
|
|
|
|
[llm.ollama]
|
|
base_url = "http://localhost:11434"
|
|
model = "llama3"
|
|
|
|
[observability]
|
|
log_format = "json"
|
|
log_level = "info"
|
|
metrics_endpoint = "0.0.0.0:9090"
|
|
otlp_endpoint = ""
|
|
tracing_sample_rate = 0.1
|
|
|
|
[analytics]
|
|
backend = "none"
|
|
clickhouse_url = "http://localhost:8123"
|
|
clickhouse_database = "sentio"
|
|
|
|
[error_events]
|
|
retention_days = 30
|