Skip to content

Add REDIS_PREFIX for PHP session keys - #2626

Open
isboston wants to merge 1 commit into
nextcloud:masterfrom
isboston:bugfix/redis-session-prefix
Open

isboston wants to merge 1 commit into
nextcloud:masterfrom
isboston:bugfix/redis-session-prefix

Conversation

@isboston

Copy link
Copy Markdown

Fixes #2621.

I reproduced this with a Redis ACL that only allows lab:*. Nextcloud's cache prefix was set to lab:, but PHP sessions still used PHPREDIS_SESSION:. Redis rejected the session lock with NOPERM.

This change adds REDIS_PREFIX for PHP sessions and their locks. With REDIS_PREFIX=lab:, the session can be saved and read using the same restricted ACL.

The prefix is URL-encoded, and the query string is handled for connections both with and without authentication. When the variable is unset or empty, the existing behaviour stays the same. Nextcloud's memcache_customprefix still needs to be configured separately.

Tested with Nextcloud 35.0.3 Apache, PHP 8.5.12, phpredis 6.3.0 and Redis 7.4:

  • The original entrypoint failed with NOPERM; the patched one passed the session write/read check.
  • 12 Redis integration checks passed, covering authentication options, Unix sockets, password files, default/empty/custom prefixes and special characters.
  • 16 configuration-generation checks passed.
  • I checked login, logout, logging in again, and creating a folder and file in the browser.
  • Automated anonymous requests to a public share and its download succeeded, and the downloaded content matched.

The Redis ACL log remained empty after testing. The full image-build matrix has not been run locally.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI.

Codex helped with the patch, automated test scripts and wording of this description.

Allow PHP sessions and their locks to use a configurable key prefix when
Redis ACLs restrict key access. URL-encode the prefix and support connections
with or without authentication. Keep the default prefix when REDIS_PREFIX
is unset or empty, and document the scope of the setting.

Refs: nextcloud#2621

Assisted-by: Codex:GPT-6
Signed-off-by: Vladimir Ischenko <kulemin1991@gmail.com>
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.

Support for Redis Prefix

1 participant