Loading go-apps/meep-gis-engine/go.mod +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions v0.0.0 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.4 ) Loading @@ -22,4 +23,5 @@ replace ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis => ../../go-packages/meep-postgis github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client => ../../go-packages/meep-sandbox-ctrl-client github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions => ../../go-packages/meep-sessions ) go-apps/meep-gis-engine/go.sum +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YAR github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ= github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= Loading @@ -30,6 +34,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= Loading go-apps/meep-gis-engine/main.go +12 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( server "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-gis-engine/server" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" "github.com/gorilla/handlers" ) Loading Loading @@ -66,7 +67,17 @@ func main() { } // Start GIS Engine REST API Server router := server.NewRouter() accessMap := map[string]string{ "Index": ss.AccessBlock, "GetAutomationState": ss.AccessVerify, "GetAutomationStateByName": ss.AccessVerify, "SetAutomationStateByName": ss.AccessVerify, "DeleteGeoDataByName": ss.AccessBlock, "GetAssetData": ss.AccessVerify, "GetGeoDataByName": ss.AccessVerify, "UpdateGeoDataByName": ss.AccessBlock, } router := server.NewRouter(accessMap) methods := handlers.AllowedMethods([]string{"DELETE", "GET", "POST"}) header := handlers.AllowedHeaders([]string{"content-type"}) log.Fatal(http.ListenAndServe(":80", handlers.CORS(methods, header)(router))) Loading go-apps/meep-gis-engine/server/gis-engine.go +10 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import ( mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" postgis "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis" sbox "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" "github.com/gorilla/mux" ) Loading Loading @@ -73,6 +74,7 @@ type GisEngine struct { handlerId int sboxCtrlClient *sbox.APIClient activeModel *mod.Model sessionStore *ss.SessionStore pc *postgis.Connector assets map[string]Asset uePoaInfo map[string]PoaInfo Loading Loading @@ -135,6 +137,14 @@ func Init() (err error) { return err } // Connect to Session Store ge.sessionStore, err = ss.NewSessionStore(redisAddr) if err != nil { log.Error("Failed connection to Session Store: ", err.Error()) return err } log.Info("Connected to Session Store") // Connect to Postgis DB ge.pc, err = postgis.NewConnector(moduleName, ge.sandboxName, postgisUser, postgisPwd, "", "") if err != nil { Loading go-apps/meep-gis-engine/server/routers.go +24 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import ( "strings" "github.com/gorilla/mux" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" ) type Route struct { Loading @@ -37,16 +39,29 @@ type Route struct { Method string Pattern string HandlerFunc http.HandlerFunc AccessType string } type Routes []Route func NewRouter() *mux.Router { func NewRouter(accessMap map[string]string) *mux.Router { router := mux.NewRouter().StrictSlash(true) for _, route := range routes { var handler http.Handler = route.HandlerFunc handler = Logger(handler, route.Name) // Authorization accessType, found := accessMap[route.Name] if !found { accessType = route.AccessType } if accessType == ss.AccessBlock { handler = ge.sessionStore.AccessBlocker(handler) } else if accessType == ss.AccessVerify { handler = ge.sessionStore.AccessVerifier(handler) } router. Methods(route.Method). Path(route.Pattern). Loading @@ -67,6 +82,7 @@ var routes = Routes{ "GET", "/gis/v1/", Index, ss.AccessGrant, }, Route{ Loading @@ -74,6 +90,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/automation", GetAutomationState, ss.AccessGrant, }, Route{ Loading @@ -81,6 +98,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/automation/{type}", GetAutomationStateByName, ss.AccessGrant, }, Route{ Loading @@ -88,6 +106,7 @@ var routes = Routes{ strings.ToUpper("Post"), "/gis/v1/automation/{type}", SetAutomationStateByName, ss.AccessGrant, }, Route{ Loading @@ -95,6 +114,7 @@ var routes = Routes{ strings.ToUpper("Delete"), "/gis/v1/geodata/{assetName}", DeleteGeoDataByName, ss.AccessGrant, }, Route{ Loading @@ -102,6 +122,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/geodata", GetAssetData, ss.AccessGrant, }, Route{ Loading @@ -109,6 +130,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/geodata/{assetName}", GetGeoDataByName, ss.AccessGrant, }, Route{ Loading @@ -116,5 +138,6 @@ var routes = Routes{ strings.ToUpper("Post"), "/gis/v1/geodata/{assetName}", UpdateGeoDataByName, ss.AccessGrant, }, } Loading
go-apps/meep-gis-engine/go.mod +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions v0.0.0 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.4 ) Loading @@ -22,4 +23,5 @@ replace ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis => ../../go-packages/meep-postgis github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client => ../../go-packages/meep-sandbox-ctrl-client github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions => ../../go-packages/meep-sessions )
go-apps/meep-gis-engine/go.sum +6 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YAR github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ= github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= Loading @@ -30,6 +34,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= Loading
go-apps/meep-gis-engine/main.go +12 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import ( server "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-gis-engine/server" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" "github.com/gorilla/handlers" ) Loading Loading @@ -66,7 +67,17 @@ func main() { } // Start GIS Engine REST API Server router := server.NewRouter() accessMap := map[string]string{ "Index": ss.AccessBlock, "GetAutomationState": ss.AccessVerify, "GetAutomationStateByName": ss.AccessVerify, "SetAutomationStateByName": ss.AccessVerify, "DeleteGeoDataByName": ss.AccessBlock, "GetAssetData": ss.AccessVerify, "GetGeoDataByName": ss.AccessVerify, "UpdateGeoDataByName": ss.AccessBlock, } router := server.NewRouter(accessMap) methods := handlers.AllowedMethods([]string{"DELETE", "GET", "POST"}) header := handlers.AllowedHeaders([]string{"content-type"}) log.Fatal(http.ListenAndServe(":80", handlers.CORS(methods, header)(router))) Loading
go-apps/meep-gis-engine/server/gis-engine.go +10 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import ( mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq" postgis "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-postgis" sbox "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" "github.com/gorilla/mux" ) Loading Loading @@ -73,6 +74,7 @@ type GisEngine struct { handlerId int sboxCtrlClient *sbox.APIClient activeModel *mod.Model sessionStore *ss.SessionStore pc *postgis.Connector assets map[string]Asset uePoaInfo map[string]PoaInfo Loading Loading @@ -135,6 +137,14 @@ func Init() (err error) { return err } // Connect to Session Store ge.sessionStore, err = ss.NewSessionStore(redisAddr) if err != nil { log.Error("Failed connection to Session Store: ", err.Error()) return err } log.Info("Connected to Session Store") // Connect to Postgis DB ge.pc, err = postgis.NewConnector(moduleName, ge.sandboxName, postgisUser, postgisPwd, "", "") if err != nil { Loading
go-apps/meep-gis-engine/server/routers.go +24 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import ( "strings" "github.com/gorilla/mux" ss "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions" ) type Route struct { Loading @@ -37,16 +39,29 @@ type Route struct { Method string Pattern string HandlerFunc http.HandlerFunc AccessType string } type Routes []Route func NewRouter() *mux.Router { func NewRouter(accessMap map[string]string) *mux.Router { router := mux.NewRouter().StrictSlash(true) for _, route := range routes { var handler http.Handler = route.HandlerFunc handler = Logger(handler, route.Name) // Authorization accessType, found := accessMap[route.Name] if !found { accessType = route.AccessType } if accessType == ss.AccessBlock { handler = ge.sessionStore.AccessBlocker(handler) } else if accessType == ss.AccessVerify { handler = ge.sessionStore.AccessVerifier(handler) } router. Methods(route.Method). Path(route.Pattern). Loading @@ -67,6 +82,7 @@ var routes = Routes{ "GET", "/gis/v1/", Index, ss.AccessGrant, }, Route{ Loading @@ -74,6 +90,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/automation", GetAutomationState, ss.AccessGrant, }, Route{ Loading @@ -81,6 +98,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/automation/{type}", GetAutomationStateByName, ss.AccessGrant, }, Route{ Loading @@ -88,6 +106,7 @@ var routes = Routes{ strings.ToUpper("Post"), "/gis/v1/automation/{type}", SetAutomationStateByName, ss.AccessGrant, }, Route{ Loading @@ -95,6 +114,7 @@ var routes = Routes{ strings.ToUpper("Delete"), "/gis/v1/geodata/{assetName}", DeleteGeoDataByName, ss.AccessGrant, }, Route{ Loading @@ -102,6 +122,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/geodata", GetAssetData, ss.AccessGrant, }, Route{ Loading @@ -109,6 +130,7 @@ var routes = Routes{ strings.ToUpper("Get"), "/gis/v1/geodata/{assetName}", GetGeoDataByName, ss.AccessGrant, }, Route{ Loading @@ -116,5 +138,6 @@ var routes = Routes{ strings.ToUpper("Post"), "/gis/v1/geodata/{assetName}", UpdateGeoDataByName, ss.AccessGrant, }, }