Loading charts/meep-platform-ctrl/templates/deployment.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ spec: env: {{- range $key, $value := .Values.image.env }} - name: {{ $key }} value: {{ $value }} value: {{ $value | quote }} {{- end }} {{- if .Values.user.frontend.enabled}} - name: USER_FRONTEND Loading charts/meep-platform-ctrl/values.yaml +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ image: pullPolicy: Always env: MEEP_SESSION_KEY: "my-secret-key" MEEP_MAX_SESSIONS: "10" service: type: ClusterIP Loading go-apps/meep-platform-ctrl/server/platform-ctrl.go +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import ( "io/ioutil" "math/rand" "net/http" "os" "strconv" "time" "github.com/gorilla/mux" Loading Loading @@ -51,6 +53,7 @@ type PlatformCtrl struct { sandboxStore *ss.SandboxStore userStore *users.Connector mqGlobal *mq.MsgQueue maxSessions int } const scenarioDBName = "scenarios" Loading Loading @@ -82,6 +85,12 @@ func Init() (err error) { // Create new Platform Controller pfmCtrl = new(PlatformCtrl) // Retrieve maximum session count from environment variable if maxSessions, err := strconv.ParseInt(os.Getenv("MEEP_MAX_SESSIONS"), 10, 0); err == nil { pfmCtrl.maxSessions = int(maxSessions) } log.Info("MEEP_MAX_SESSIONS: ", pfmCtrl.maxSessions) // Create message queue pfmCtrl.mqGlobal, err = mq.NewMsgQueue(mq.GetGlobalName(), moduleName, moduleNamespace, redisDBAddr) if err != nil { Loading go-apps/meep-platform-ctrl/server/user_authentication.go +9 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,15 @@ func uaLoginUser(w http.ResponseWriter, r *http.Request) { sessionStore := pfmCtrl.sessionMgr.GetSessionStore() session, err := sessionStore.GetByName(username) if err != nil { // Check if max session count is reached before creating a new one count := sessionStore.GetCount() if count >= pfmCtrl.maxSessions { err = errors.New("Maximum session count exceeded") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInsufficientStorage) return } // Get requested sandbox name from user profile, if any user, err := pfmCtrl.userStore.GetUser(username) if err == nil { Loading go-packages/meep-sessions/session-store.go +12 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,18 @@ func (ss *SessionStore) Get(r *http.Request) (s *Session, err error) { return s, nil } // GetCount - Retrieve session count func (ss *SessionStore) GetCount() (count int) { _ = ss.rc.ForEachEntry(ss.baseKey+"*", getCountHandler, &count) return count } func getCountHandler(key string, fields map[string]string, userData interface{}) error { count := userData.(*int) *count += 1 return nil } // GetAll - Retrieve session by name func (ss *SessionStore) GetAll() (sessionList []*Session, err error) { // Get all sessions, if any Loading Loading
charts/meep-platform-ctrl/templates/deployment.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ spec: env: {{- range $key, $value := .Values.image.env }} - name: {{ $key }} value: {{ $value }} value: {{ $value | quote }} {{- end }} {{- if .Values.user.frontend.enabled}} - name: USER_FRONTEND Loading
charts/meep-platform-ctrl/values.yaml +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ image: pullPolicy: Always env: MEEP_SESSION_KEY: "my-secret-key" MEEP_MAX_SESSIONS: "10" service: type: ClusterIP Loading
go-apps/meep-platform-ctrl/server/platform-ctrl.go +9 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import ( "io/ioutil" "math/rand" "net/http" "os" "strconv" "time" "github.com/gorilla/mux" Loading Loading @@ -51,6 +53,7 @@ type PlatformCtrl struct { sandboxStore *ss.SandboxStore userStore *users.Connector mqGlobal *mq.MsgQueue maxSessions int } const scenarioDBName = "scenarios" Loading Loading @@ -82,6 +85,12 @@ func Init() (err error) { // Create new Platform Controller pfmCtrl = new(PlatformCtrl) // Retrieve maximum session count from environment variable if maxSessions, err := strconv.ParseInt(os.Getenv("MEEP_MAX_SESSIONS"), 10, 0); err == nil { pfmCtrl.maxSessions = int(maxSessions) } log.Info("MEEP_MAX_SESSIONS: ", pfmCtrl.maxSessions) // Create message queue pfmCtrl.mqGlobal, err = mq.NewMsgQueue(mq.GetGlobalName(), moduleName, moduleNamespace, redisDBAddr) if err != nil { Loading
go-apps/meep-platform-ctrl/server/user_authentication.go +9 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,15 @@ func uaLoginUser(w http.ResponseWriter, r *http.Request) { sessionStore := pfmCtrl.sessionMgr.GetSessionStore() session, err := sessionStore.GetByName(username) if err != nil { // Check if max session count is reached before creating a new one count := sessionStore.GetCount() if count >= pfmCtrl.maxSessions { err = errors.New("Maximum session count exceeded") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInsufficientStorage) return } // Get requested sandbox name from user profile, if any user, err := pfmCtrl.userStore.GetUser(username) if err == nil { Loading
go-packages/meep-sessions/session-store.go +12 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,18 @@ func (ss *SessionStore) Get(r *http.Request) (s *Session, err error) { return s, nil } // GetCount - Retrieve session count func (ss *SessionStore) GetCount() (count int) { _ = ss.rc.ForEachEntry(ss.baseKey+"*", getCountHandler, &count) return count } func getCountHandler(key string, fields map[string]string, userData interface{}) error { count := userData.(*int) *count += 1 return nil } // GetAll - Retrieve session by name func (ss *SessionStore) GetAll() (sessionList []*Session, err error) { // Get all sessions, if any Loading