Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2621.
I reproduced this with a Redis ACL that only allows
lab:*. Nextcloud's cache prefix was set tolab:, but PHP sessions still usedPHPREDIS_SESSION:. Redis rejected the session lock withNOPERM.This change adds
REDIS_PREFIXfor PHP sessions and their locks. WithREDIS_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_customprefixstill needs to be configured separately.Tested with Nextcloud 35.0.3 Apache, PHP 8.5.12, phpredis 6.3.0 and Redis 7.4:
NOPERM; the patched one passed the session write/read check.The Redis ACL log remained empty after testing. The full image-build matrix has not been run locally.
🤖 AI (if applicable)
Codex helped with the patch, automated test scripts and wording of this description.