From b204a230504ded3eb21c2bff611d7604fea39316 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 6 May 2026 22:38:49 +0200 Subject: [PATCH 1/2] feat: move Symfony sessions to Redis, env-configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit framework.session.handler_id now reads from SESSION_HANDLER_DSN, which defaults to the existing REDIS_CACHE_DSN so dev (and prod that has Redis available) gets Redis-backed sessions out of the box. Operators can set SESSION_HANDLER_DSN= (empty) to fall back to PHP's native file handler. Why move: - Removes the per-session flock that serialises parallel session-touching requests on the file handler (visible as inconsistent tail latency when the React admin fires concurrent fetches). - Sessions survive container restarts without mounting /tmp as a volume. - Multi-pod deployments share session state without sticky routing — the OIDC handshake works regardless of which pod handles the callback. The new RedisSessionHandler is auto-built by Symfony from the DSN; it prefixes keys with `sf_s` so they don't collide with cache keys on the same Redis DB. when@test forces handler_id back to null, since MockFileSessionStorage doesn't go through a handler and we don't want the test container to compile a Redis handler against an env that may not point at a reachable Redis. Verified locally: HTTP request to /v2/authentication/oidc/urls writes a `sf_s` key into Redis; full PHPUnit suite (143 tests, 607 assertions) passes with redis DBSIZE=0 after, confirming the test override works. Co-Authored-By: Claude Opus 4.7 (1M context) --- .env | 7 +++++++ CHANGELOG.md | 7 +++++++ config/packages/framework.yaml | 12 +++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.env b/.env index b386b81a..7f24d7d7 100644 --- a/.env +++ b/.env @@ -72,6 +72,13 @@ JWT_SCREEN_REFRESH_TOKEN_TTL=2592000 REDIS_CACHE_PREFIX=DisplayApiService # Connection string for Redis cache server. REDIS_CACHE_DSN=redis://redis:6379/0 +# Session storage backend, consumed by framework.session.handler_id. +# A `redis://...` DSN makes Symfony auto-build a RedisSessionHandler (with +# its own `sf_s` key prefix, so cache and session keys don't collide on +# the same DB). Empty value = PHP's native file handler; pick that for +# single-pod deployments that don't care about flock-induced tail latency +# or container-restart session survival. +SESSION_HANDLER_DSN=${REDIS_CACHE_DSN} ###< redis ### ###> Http Client ### diff --git a/CHANGELOG.md b/CHANGELOG.md index 703a51ec..035dfb9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,15 @@ All notable changes to this project will be documented in this file. - Aligned API and Nginx image labels with the OCI image spec: dropped deprecated `LABEL maintainer`, added `org.opencontainers.image.{authors,vendor,documentation,base.name}`, and fixed the Nginx image's `title`/`description` so it stops inheriting the source-repo defaults. +<<<<<<< HEAD - Bumped the local dev Redis image from `redis:6` to `redis:8`. Production deployments are unaffected (they bring their own Redis); Symfony 6.4's cache adapter and the bundled phpredis 6.3 work as-is. +======= +- Switched Symfony session storage to Redis (default `SESSION_HANDLER_DSN=${REDIS_CACHE_DSN}`); set + `SESSION_HANDLER_DSN=` empty to fall back to PHP's native file handler. Removes the per-session + `flock` that serialised parallel session-touching requests and lets sessions survive container + restarts; multi-pod deployments now share session state without sticky routing. +>>>>>>> e4abf911 (feat: move Symfony sessions to Redis, env-configurable) ## [3.0.0-rc2] - 2026-05-05 diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 7de6acc6..92b6243f 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -9,7 +9,13 @@ framework: # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. session: - handler_id: null + # Empty falls back to PHP's native file handler; a `redis://...` DSN + # makes Symfony auto-build a RedisSessionHandler. See SESSION_HANDLER_DSN + # in .env. Redis-backed sessions remove the per-session flock that + # serialises parallel requests on the file handler and survive + # container restarts; local dev gets the same behaviour because the + # default DSN points at the compose Redis. + handler_id: '%env(SESSION_HANDLER_DSN)%' cookie_secure: auto cookie_samesite: lax storage_factory_id: session.storage.factory.native @@ -33,4 +39,8 @@ when@test: framework: test: true session: + # MockFileSessionStorage keeps tests off Redis; force handler_id + # back to native so the Redis handler service isn't compiled + # against an env that may not point at a reachable Redis. + handler_id: null storage_factory_id: session.storage.factory.mock_file From 2f1542ccfda5afae4ed7cb05673c51dc45a6b619 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Thu, 7 May 2026 11:15:29 +0200 Subject: [PATCH 2/2] fix: remove conflict markers left in CHANGELOG by botched rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous rebase commit silently committed CHANGELOG.md with `<<<<<<<` / `=======` / `>>>>>>>` markers still in place — the Edit that resolved them lost a race against the git rebase tooling touching the same file, but `git add CHANGELOG.md` accepted the broken bytes and `git rebase --continue` succeeded. CI's markdownlint job (MD032) caught it. Both bullets are kept. Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 035dfb9f..8d7ad78e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,12 @@ All notable changes to this project will be documented in this file. - Aligned API and Nginx image labels with the OCI image spec: dropped deprecated `LABEL maintainer`, added `org.opencontainers.image.{authors,vendor,documentation,base.name}`, and fixed the Nginx image's `title`/`description` so it stops inheriting the source-repo defaults. -<<<<<<< HEAD - Bumped the local dev Redis image from `redis:6` to `redis:8`. Production deployments are unaffected (they bring their own Redis); Symfony 6.4's cache adapter and the bundled phpredis 6.3 work as-is. -======= - Switched Symfony session storage to Redis (default `SESSION_HANDLER_DSN=${REDIS_CACHE_DSN}`); set `SESSION_HANDLER_DSN=` empty to fall back to PHP's native file handler. Removes the per-session `flock` that serialised parallel session-touching requests and lets sessions survive container restarts; multi-pod deployments now share session state without sticky routing. ->>>>>>> e4abf911 (feat: move Symfony sessions to Redis, env-configurable) ## [3.0.0-rc2] - 2026-05-05