Core session keys have no prefix, so Harbor cannot share a Redis/ACL-scoped instance
Every Redis key Harbor core writes into the core database is namespaced except one family:
| Writer | Key shape |
|---|---|
business cache (lib/cache.Initialize) |
cache:… |
cache layer (lib/cache.LayerCache) |
cache:… |
| jobservice | {harbor_job_service_namespace}:… |
beego sessions (core/session) |
<session id>, a bare 32-char id |
With Redis ACLs (Redis 6+, Valkey, Dragonfly), a shared instance gives each tenant a user limited to its own key pattern (~harbor:*). Harbor can't be that tenant, because its session keys don't match any pattern except ~*. The operator then has two options:
- give Harbor a dedicated Redis instance;
- grant Harbor all keys, which gives it read/write access to other tenants' data.
Using a separate logical DB doesn't solve this. ACLs are not scoped per DB, and Redis Cluster and Dragonfly-style deployments often expose only DB 0.
Harbor 2.15 added REDIS_USERNAME support for the registry (#22770), so ACL-scoped users already work end to end. The one remaining gap is a key prefix for sessions.
proposed solution
An optional key prefix for the session store, read from _REDIS_SESSION_KEY_PREFIX. Later it can be exposed through the Helm chart and harbor.yml like the other _REDIS_* settings.
- If it's unset (the default), behaviour is unchanged. Existing sessions stay valid across upgrades, so nobody gets logged out.
- If it's set, all session keys are written as
<prefix><sid>.
The lib/cache layer already supports Options.Prefix. However, core/session builds its cache without one, and it also calls the raw go-redis client directly in two places, which would bypass a prefix even if one were set:
Store.releaseSession:rdb.Client.Set/SetXXwithrs.sid;Provider.SessionRegenerate:rdb.Rename/rdb.Expirewith the bare ids.
The fix has to cover both places.
alternatives considered
- A dedicated Redis/Dragonfly instance per Harbor, which is what we run today. It works, but it's an extra stateful service to operate for a few hundred keys.
allkeysfor the Harbor user on a shared instance. This breaks tenant isolation.- A separate DB index. ACLs aren't per DB, so this gives no isolation.
Source: goharbor/harbor