diff --git a/bootstrap/config/config.go b/bootstrap/config/config.go index ae02c372..ac9afff9 100644 --- a/bootstrap/config/config.go +++ b/bootstrap/config/config.go @@ -60,8 +60,7 @@ const ( appServicesKey = "app-services" deviceServicesKey = "device-services" - SecurityModeKey = "Mode" - OpenZitiServiceNameKey = "OpenZitiServiceName" + SecurityModeKey = "Mode" ) var invalidRemoteHostsError = errors.New("-rsh/--remoteServiceHosts must contain 3 and only 3 comma seperated host names") diff --git a/bootstrap/handlers/httpserver.go b/bootstrap/handlers/httpserver.go index bed2d59a..a2c482b0 100644 --- a/bootstrap/handlers/httpserver.go +++ b/bootstrap/handlers/httpserver.go @@ -51,6 +51,7 @@ type HttpServer struct { router *echo.Echo isRunning bool doListenAndServe bool + serverKey string } type ZitiContext struct { @@ -59,11 +60,12 @@ type ZitiContext struct { type OpenZitiIdentityKey struct{} // NewHttpServer is a factory method that returns an initialized HttpServer receiver struct. -func NewHttpServer(router *echo.Echo, doListenAndServe bool) *HttpServer { +func NewHttpServer(router *echo.Echo, doListenAndServe bool, serviceKey string) *HttpServer { return &HttpServer{ router: router, isRunning: false, doListenAndServe: doListenAndServe, + serverKey: serviceKey, } } @@ -214,10 +216,11 @@ func (b *HttpServer) BootstrapHandler( break } - serviceName := bootstrapConfig.Service.SecurityOptions[config.OpenZitiServiceNameKey] - ln, listenErr := zitiCtx.Listen(serviceName) + ozServiceName := zerotrust.OpenZitiServicePrefix + b.serverKey + lc.Infof("Using OpenZiti service name: %s", ozServiceName) + ln, listenErr := zitiCtx.Listen(ozServiceName) if listenErr != nil { - err = fmt.Errorf("could not bind service " + serviceName + ": " + listenErr.Error()) + err = fmt.Errorf("could not bind service " + ozServiceName + ": " + listenErr.Error()) break } diff --git a/bootstrap/zerotrust/zerotrust.go b/bootstrap/zerotrust/zerotrust.go index e21652e2..ec5c283e 100644 --- a/bootstrap/zerotrust/zerotrust.go +++ b/bootstrap/zerotrust/zerotrust.go @@ -16,6 +16,7 @@ import ( const ( OpenZitiControllerKey = "OpenZitiController" ZeroTrustMode = "zerotrust" + OpenZitiServicePrefix = "edgex." ) func AuthToOpenZiti(ozController, jwt string) (ziti.Context, error) {