Configuring session namespace does not change activeSessionsKey
goeh opened this issue · 0 comments
Task List
- Steps to reproduce provided
- Stacktrace (if present) provided
- Example that reproduces the problem uploaded to Github
- Full description of the issue provided (see below)
Steps to Reproduce
Change the default namespace for session keys in Redis:
micronaut.session.http.redis.namespace: 'myapp_sessions:'
Sessions are stored in Redis with the namespace prefix, but the key holding active sessions still uses the default prefix micronaut.session:
If you want active sessions to be under the same namespace you must also change active-sessions-key
to include your namespace prefix, like this:
micronaut.session.http.redis.active-sessions-key: 'myapp_sessions:active-sessions'
Expected Behaviour
I expected active sessions to be stored with the namespace prefix when I configured namespace.
Actual Behaviour
Active sessions uses the default prefix "micronaut.session:' unless you explicitly configure micronaut.session.http.redis.active-sessions-key
.
The key is prefixed with namespace when the class is instantiated but it is not changed when namespace is changed.
https://github.com/micronaut-projects/micronaut-redis/blob/master/redis-lettuce/src/main/java/io/micronaut/configuration/lettuce/session/RedisHttpSessionConfiguration.java#L42
IMO the behavior should be changed. If that's not possible due to the breaking change, it should be documented with a warning to avoid unexpected namespace pollution.
Some might argue that finding all active sessions (cross namespaces) using a single key is a feature. But I think that's a corner case.
Environment Information
- Operating System: MacOS 10.15.5
- Micronaut Version: 1.3.7
- JDK Version: OpenJDK 11.0.7
Example Application
- TODO: link to github repository with example that reproduces the issue