Commit 19c26811 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

initial import

parent 01b832f5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,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-redis v0.0.0
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions-manager v0.0.0
	github.com/gorilla/handlers v1.4.0
	github.com/gorilla/mux v1.7.3
	golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect
@@ -30,4 +31,5 @@ replace (
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq => ../../go-packages/meep-mq
	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-sessions-manager => ../../go-packages/meep-sessions-manager
)
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZs
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
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/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e h1:txQltCyjXAqVVSZDArPEhUTg35hKwVIuXwtQo7eAMNQ=
github.com/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
@@ -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=
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020  InterDigital Communications, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the \"License\");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an \"AS IS\" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * AdvantEDGE Location Service REST API
 *
 * Location Service is AdvantEDGE's implementation of [ETSI MEC ISG MEC013 Location API](http://www.etsi.org/deliver/etsi_gs/MEC/001_099/013/01.01.01_60/gs_mec013v010101p.pdf) <p>The API is based on the Open Mobile Alliance's specification RESTful Network API for Zonal Presence <p>[Copyright (c) ETSI 2017](https://forge.etsi.org/etsi-forge-copyright-notice.txt) <p>**Micro-service**<br>[meep-loc-serv](https://github.com/InterDigitalInc/AdvantEDGE/tree/master/go-apps/meep-loc-serv) <p>**Type & Usage**<br>Edge Service used by edge applications that want to get information about Users (UE) and Zone locations <p>**Details**<br>API details available at _your-AdvantEDGE-ip-address/api_
 *
 * API version: 1.1.1
 * Contact: AdvantEDGE@InterDigital.com
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */

package server

import (
	"net/http"

	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
	sm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sessions-manager"
)

func init() {
	_ = sm.Init("")
}

func Authentication(inner http.Handler, authenticationNeeded bool) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		log.Info("SIMON authCookie")
		if authenticationNeeded {
			if sm.IsActiveSession(r) {
				inner.ServeHTTP(w, r)
			} else {
				http.Error(w, "Unauthorized", http.StatusUnauthorized)
			}
		} else {
			inner.ServeHTTP(w, r)
		}
	})
}
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import (

func Logger(inner http.Handler, name string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		log.Info("SIMON logger")
		start := time.Now()

		inner.ServeHTTP(w, r)
+28 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ type Route struct {
	Method             string
	Pattern            string
	HandlerFunc        http.HandlerFunc
	NeedAuthentication bool
}

type Routes []Route
@@ -49,6 +50,7 @@ func NewRouter() *mux.Router {
		var handler http.Handler = route.HandlerFunc
		handler = Logger(handler, route.Name)
		handler = httpLog.LogRx(handler, "")
		handler = Authentication(handler, route.NeedAuthentication)

		router.
			Methods(route.Method).
@@ -70,6 +72,7 @@ var routes = Routes{
		"GET",
		"/location/v1/",
		Index,
		false,
	},

	Route{
@@ -77,6 +80,7 @@ var routes = Routes{
		strings.ToUpper("Delete"),
		"/location/v1/subscriptions/userTracking/{subscriptionId}",
		UserTrackingSubDelById,
		false,
	},

	Route{
@@ -84,6 +88,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/userTracking",
		UserTrackingSubGet,
		false,
	},

	Route{
@@ -91,6 +96,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/userTracking/{subscriptionId}",
		UserTrackingSubGetById,
		false,
	},

	Route{
@@ -98,6 +104,7 @@ var routes = Routes{
		strings.ToUpper("Post"),
		"/location/v1/subscriptions/userTracking",
		UserTrackingSubPost,
		false,
	},

	Route{
@@ -105,6 +112,7 @@ var routes = Routes{
		strings.ToUpper("Put"),
		"/location/v1/subscriptions/userTracking/{subscriptionId}",
		UserTrackingSubPutById,
		false,
	},

	Route{
@@ -112,6 +120,7 @@ var routes = Routes{
		strings.ToUpper("Delete"),
		"/location/v1/subscriptions/zonalTraffic/{subscriptionId}",
		ZonalTrafficSubDelById,
		false,
	},

	Route{
@@ -119,6 +128,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/zonalTraffic",
		ZonalTrafficSubGet,
		false,
	},

	Route{
@@ -126,6 +136,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/zonalTraffic/{subscriptionId}",
		ZonalTrafficSubGetById,
		false,
	},

	Route{
@@ -133,6 +144,7 @@ var routes = Routes{
		strings.ToUpper("Post"),
		"/location/v1/subscriptions/zonalTraffic",
		ZonalTrafficSubPost,
		false,
	},

	Route{
@@ -140,6 +152,7 @@ var routes = Routes{
		strings.ToUpper("Put"),
		"/location/v1/subscriptions/zonalTraffic/{subscriptionId}",
		ZonalTrafficSubPutById,
		false,
	},

	Route{
@@ -147,6 +160,7 @@ var routes = Routes{
		strings.ToUpper("Delete"),
		"/location/v1/subscriptions/zoneStatus/{subscriptionId}",
		ZoneStatusDelById,
		false,
	},

	Route{
@@ -154,6 +168,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/zonalStatus",
		ZoneStatusGet,
		false,
	},

	Route{
@@ -161,6 +176,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/subscriptions/zoneStatus/{subscriptionId}",
		ZoneStatusGetById,
		false,
	},

	Route{
@@ -168,6 +184,7 @@ var routes = Routes{
		strings.ToUpper("Post"),
		"/location/v1/subscriptions/zonalStatus",
		ZoneStatusPost,
		false,
	},

	Route{
@@ -175,6 +192,7 @@ var routes = Routes{
		strings.ToUpper("Put"),
		"/location/v1/subscriptions/zoneStatus/{subscriptionId}",
		ZoneStatusPutById,
		false,
	},

	Route{
@@ -182,6 +200,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/users",
		UsersGet,
		false,
	},

	Route{
@@ -189,6 +208,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/users/{userId}",
		UsersGetById,
		true,
	},

	Route{
@@ -196,6 +216,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/zones/{zoneId}/accessPoints",
		ZonesByIdGetAps,
		false,
	},

	Route{
@@ -203,6 +224,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/zones/{zoneId}/accessPoints/{accessPointId}",
		ZonesByIdGetApsById,
		false,
	},

	Route{
@@ -210,6 +232,7 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/zones",
		ZonesGet,
		false,
	},

	Route{
@@ -217,5 +240,6 @@ var routes = Routes{
		strings.ToUpper("Get"),
		"/location/v1/zones/{zoneId}",
		ZonesGetById,
		false,
	},
}
Loading