Skip to content

Add optional cookie allowlist for forwarded tracking requests - #105

Merged
sgiehl merged 3 commits into
masterfrom
dev-19992
Jul 3, 2026
Merged

Add optional cookie allowlist for forwarded tracking requests#105
sgiehl merged 3 commits into
masterfrom
dev-19992

Conversation

@sgiehl

@sgiehl sgiehl commented Jul 2, 2026

Copy link
Copy Markdown
Member

Fixes #99.

Adds an opt-in $COOKIE_ALLOWLIST config array to restrict which cookies the proxy forwards to Matomo, instead of always forwarding the entire Cookie header. Entries ending in * prefix-match (for Matomo's suffixed cookies like _pk_id.1.1fff); plain entries match exactly. Unset preserves current behavior.

sgiehl added 3 commits July 2, 2026 13:42
Restricts the Cookie header sent to Matomo to configured names/prefixes
instead of forwarding all site cookies. Opt-in via $COOKIE_ALLOWLIST,
unset preserves current behavior. Fixes #99.
Fail closed instead of open when $COOKIE_ALLOWLIST is misconfigured
(non-array), document and test the '*'/'' no-op guard, trim cookie
name/value around '=', and expand docs on cookie_name_prefix,
matomo_ignore, and data-quality risks.
Use error_log() instead of trigger_error() so a misconfigured
allowlist warning can never leak into the response body when
display_errors is on. Trim allowlist entries for parity with the
already-trimmed cookie name/value parsing, add a test for a stray
empty entry among real ones, give matomo_ignore its own warning in
the README, and de-duplicate/shorten the test-only config hooks and
several overly long comments.
@sgiehl
sgiehl marked this pull request as ready for review July 2, 2026 12:52
@sgiehl
sgiehl requested a review from a team July 2, 2026 12:52

@caddoo caddoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, tested locally and it works.

Happy that it's off by default.

Looks like the only risk is use error (bad configuration).

@sgiehl
sgiehl merged commit dd225dc into master Jul 3, 2026
8 checks passed
@sgiehl
sgiehl deleted the dev-19992 branch July 3, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional configurable cookie allowlist for forwarded requests

2 participants