store extra key infront of session tokens
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user