fix: cassandra + mongo + arangodb issues with webhook
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package stores
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
)
|
||||
|
||||
// EnvStore struct to store the env variables
|
||||
@@ -23,12 +20,10 @@ func NewEnvStore() *EnvStore {
|
||||
|
||||
// UpdateEnvStore to update the whole env store object
|
||||
func (e *EnvStore) UpdateStore(store map[string]interface{}) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
e.mutex.Lock()
|
||||
defer e.mutex.Unlock()
|
||||
}
|
||||
// just override the keys + new keys
|
||||
e.mutex.Lock()
|
||||
defer e.mutex.Unlock()
|
||||
|
||||
// just override the keys + new keys
|
||||
for key, value := range store {
|
||||
e.store[key] = value
|
||||
}
|
||||
@@ -46,9 +41,8 @@ func (e *EnvStore) Get(key string) interface{} {
|
||||
|
||||
// Set sets the value of the key in env store
|
||||
func (e *EnvStore) Set(key string, value interface{}) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
e.mutex.Lock()
|
||||
defer e.mutex.Unlock()
|
||||
}
|
||||
e.mutex.Lock()
|
||||
defer e.mutex.Unlock()
|
||||
|
||||
e.store[key] = value
|
||||
}
|
||||
|
@@ -1,11 +1,8 @@
|
||||
package stores
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
)
|
||||
|
||||
// SessionStore struct to store the env variables
|
||||
@@ -29,10 +26,9 @@ func (s *SessionStore) Get(key, subKey string) string {
|
||||
|
||||
// Set sets the value of the key in state store
|
||||
func (s *SessionStore) Set(key string, subKey, value string) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if _, ok := s.store[key]; !ok {
|
||||
s.store[key] = make(map[string]string)
|
||||
}
|
||||
@@ -41,19 +37,15 @@ func (s *SessionStore) Set(key string, subKey, value string) {
|
||||
|
||||
// RemoveAll all values for given key
|
||||
func (s *SessionStore) RemoveAll(key string) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
delete(s.store, key)
|
||||
}
|
||||
|
||||
// Remove value for given key and subkey
|
||||
func (s *SessionStore) Remove(key, subKey string) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
if _, ok := s.store[key]; ok {
|
||||
delete(s.store[key], subKey)
|
||||
}
|
||||
@@ -69,11 +61,8 @@ func (s *SessionStore) GetAll(key string) map[string]string {
|
||||
|
||||
// RemoveByNamespace to delete session for a given namespace example google,github
|
||||
func (s *SessionStore) RemoveByNamespace(namespace string) error {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
for key := range s.store {
|
||||
if strings.Contains(key, namespace+":") {
|
||||
delete(s.store, key)
|
||||
|
@@ -1,10 +1,7 @@
|
||||
package stores
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
)
|
||||
|
||||
// StateStore struct to store the env variables
|
||||
@@ -28,19 +25,16 @@ func (s *StateStore) Get(key string) string {
|
||||
|
||||
// Set sets the value of the key in state store
|
||||
func (s *StateStore) Set(key string, value string) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
s.store[key] = value
|
||||
}
|
||||
|
||||
// Remove removes the key from state store
|
||||
func (s *StateStore) Remove(key string) {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
}
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
delete(s.store, key)
|
||||
}
|
||||
|
Reference in New Issue
Block a user