Skip to content

feat: support wildcard subdomain matching in trusted_domains - #1121

Merged
qwqcode merged 1 commit into
ArtalkJS:masterfrom
dono-zz:feat/wildcard-trusted-domains
Oct 28, 2026
Merged

qwqcode merged 1 commit into
ArtalkJS:masterfrom
dono-zz:feat/wildcard-trusted-domains

Conversation

@dono-zz

@dono-zz dono-zz commented Apr 6, 2026 •

Copy link
Copy Markdown

Adds single-level wildcard matching to trusted_domains and dashboard site URLs. For example, https://*.example.com allows browser requests from https://blog.example.com, but not from example.com or a.b.example.com. The scheme and port must match. This reduces configuration changes when adding subdomains.

Existing exact URL matching stays unchanged, including configured paths, custom ports, localhost, and IPv6 addresses. The matcher parses URLs and rejects malformed origins. Wildcards do not authorize page-title fetching or redirects. Those requests still require an exact trusted origin. No new configuration fields or dependencies are added.

Rebased onto the current master and removed unrelated landing-page changes. Updated the English and Chinese documentation, including the need to keep a concrete first site URL when using relative page keys.

Validation: all Go tests passed with CGO_ENABLED=0. Race tests passed for middleware, DAO, common server helpers, and handlers. go vet ./... and documentation formatting checks passed. Added tests for malformed origins, actual CORS responses and preflights, guest and authorization headers, dashboard site URLs, and title-fetch restrictions. Existing tests cover anonymous comments, page creation, and page views.

Add wildcard pattern support (e.g. `https://*.example.com`) for
trusted_domains config and site URLs. This allows dynamically trusting
all subdomains under a base domain without listing each one explicitly.

The wildcard `*` matches exactly one subdomain level — `*.example.com`
matches `sub.example.com` but not `example.com` or `a.b.example.com`.
Scheme must also match. Exact domain matching is fully preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qwqcode
qwqcode force-pushed the feat/wildcard-trusted-domains branch from 31cc5bc to 08fedee Compare October 28, 2026 16:00
@qwqcode
qwqcode merged commit 5ad3025 into ArtalkJS:master Oct 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants