store extra key infront of session tokens

This commit is contained in:
Gregory Wells
2026-06-07 20:42:09 -04:00
parent a7b302b74b
commit 4474986909
+8 -4
View File
@@ -14,6 +14,10 @@ type RedisStore struct {
ctx context.Context
}
func RedisHash(sessionID string) string {
return "selfservicedashboard_" + hashSession(sessionID)
}
func NewRedisStore() *RedisStore {
logging.Debug("Creating new redis session store")
@@ -44,7 +48,7 @@ func NewRedisStore() *RedisStore {
// return rdb.Set(ctx, key, data, 0).Err()
func (m *RedisStore) Create(sessionID string, session *SessionData) (err error) {
hashedSession := hashSession(sessionID)
hashedSession := RedisHash(sessionID)
data, err := json.Marshal(*session)
if err != nil {
@@ -63,7 +67,7 @@ func (m *RedisStore) Create(sessionID string, session *SessionData) (err error)
return nil
}
func (m *RedisStore) Get(sessionID string) (*SessionData, error) {
hashed := hashSession(sessionID)
hashed := RedisHash(sessionID)
data, err := m.client.Get(m.ctx, hashed).Bytes()
if err == redis.Nil {
@@ -87,7 +91,7 @@ func (m *RedisStore) Get(sessionID string) (*SessionData, error) {
}
func (m *RedisStore) Update(sessionID string, session *SessionData) error {
hashedSession := hashSession(sessionID)
hashedSession := RedisHash(sessionID)
data, err := json.Marshal(*session)
if err != nil {
@@ -107,7 +111,7 @@ func (m *RedisStore) Update(sessionID string, session *SessionData) error {
}
func (m *RedisStore) Delete(sessionID string) error {
hashedSession := hashSession(sessionID)
hashedSession := RedisHash(sessionID)
err := m.client.Del(m.ctx, hashedSession).Err()
if err != nil {
logging.Error(err.Error())