diff --git a/cmd/zrok/access_private.go b/cmd/zrok/access_private.go index a568f505..adbb60a6 100644 --- a/cmd/zrok/access_private.go +++ b/cmd/zrok/access_private.go @@ -38,7 +38,7 @@ func newAccessPrivateCommand() *accessPrivateCommand { } func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) { - svcName := args[0] + svcToken := args[0] endpointUrl, err := url.Parse("http://" + cmd.bindAddress) if err != nil { @@ -66,8 +66,8 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) { auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token) req := service.NewAccessParams() req.Body = &rest_model_zrok.AccessRequest{ - SvcName: svcName, - ZID: env.ZId, + SvcToken: svcToken, + EnvZID: env.ZId, } accessResp, err := zrok.Service.Access(req, auth) if err != nil { @@ -76,17 +76,17 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) { } panic(err) } - logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendName) + logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendToken) cfg := private_frontend.DefaultConfig("backend") - cfg.SvcName = svcName + cfg.SvcToken = svcToken cfg.Address = cmd.bindAddress c := make(chan os.Signal) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c - cmd.destroy(accessResp.Payload.FrontendName, env.ZId, svcName, zrok, auth) + cmd.destroy(accessResp.Payload.FrontendToken, env.ZId, svcToken, zrok, auth) os.Exit(0) }() @@ -107,13 +107,13 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) { } } -func (cmd *accessPrivateCommand) destroy(frotendName, envZId, svcName string, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) { - logrus.Debugf("shutting down '%v'", svcName) +func (cmd *accessPrivateCommand) destroy(frotendName, envZId, svcToken string, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) { + logrus.Debugf("shutting down '%v'", svcToken) req := service.NewUnaccessParams() req.Body = &rest_model_zrok.UnaccessRequest{ - FrontendName: frotendName, - SvcName: svcName, - ZID: envZId, + FrontendToken: frotendName, + SvcToken: svcToken, + EnvZID: envZId, } if _, err := zrok.Service.Unaccess(req, auth); err == nil { logrus.Debugf("shutdown complete") diff --git a/cmd/zrok/loop.go b/cmd/zrok/loop.go index 9f6762cc..fbecdccf 100644 --- a/cmd/zrok/loop.go +++ b/cmd/zrok/loop.go @@ -259,8 +259,8 @@ func (l *looper) shutdown() { untunnelReq := service.NewUnshareParams() untunnelReq.Body = &rest_model_zrok.UnshareRequest{ - ZID: l.env.ZId, - SvcName: l.service, + EnvZID: l.env.ZId, + SvcToken: l.service, } if _, err := l.zrok.Service.Unshare(untunnelReq, l.auth); err != nil { logrus.Errorf("error shutting down looper #%d: %v", l.id, err) diff --git a/cmd/zrok/share_again.go b/cmd/zrok/share_again.go index 8e69bc4a..5f9e6823 100644 --- a/cmd/zrok/share_again.go +++ b/cmd/zrok/share_again.go @@ -115,8 +115,8 @@ func (self *shareAgainCommand) destroy(id string, cfg *backend.Config, zrok *res logrus.Debugf("shutting down '%v'", cfg.Service) req := service.NewUnshareParams() req.Body = &rest_model_zrok.UnshareRequest{ - ZID: id, - SvcName: cfg.Service, + EnvZID: id, + SvcToken: cfg.Service, } if _, err := zrok.Service.Unshare(req, auth); err == nil { logrus.Debugf("shutdown complete") diff --git a/cmd/zrok/share_private.go b/cmd/zrok/share_private.go index a3b7c5dd..c5f811b6 100644 --- a/cmd/zrok/share_private.go +++ b/cmd/zrok/share_private.go @@ -149,8 +149,8 @@ func (self *sharePrivateCommand) destroy(id string, cfg *backend.Config, zrok *r logrus.Debugf("shutting down '%v'", cfg.Service) req := service.NewUnshareParams() req.Body = &rest_model_zrok.UnshareRequest{ - ZID: id, - SvcName: cfg.Service, + EnvZID: id, + SvcToken: cfg.Service, } if _, err := zrok.Service.Unshare(req, auth); err == nil { logrus.Debugf("shutdown complete") diff --git a/cmd/zrok/share_public.go b/cmd/zrok/share_public.go index 5ef0c0ca..dbda6fed 100644 --- a/cmd/zrok/share_public.go +++ b/cmd/zrok/share_public.go @@ -228,8 +228,8 @@ func (self *sharePublicCommand) destroy(id string, cfg *backend.Config, zrok *re logrus.Debugf("shutting down '%v'", cfg.Service) req := service.NewUnshareParams() req.Body = &rest_model_zrok.UnshareRequest{ - ZID: id, - SvcName: cfg.Service, + EnvZID: id, + SvcToken: cfg.Service, } if _, err := zrok.Service.Unshare(req, auth); err == nil { logrus.Debugf("shutdown complete") diff --git a/controller/access.go b/controller/access.go index 2999fbc7..14a6eae0 100644 --- a/controller/access.go +++ b/controller/access.go @@ -29,7 +29,7 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode } defer func() { _ = tx.Rollback() }() - envZId := params.Body.ZID + envZId := params.Body.EnvZID envId := 0 if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { found := false @@ -50,14 +50,14 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode return service.NewAccessNotFound() } - svcName := params.Body.SvcName - ssvc, err := str.FindServiceWithToken(svcName, tx) + svcToken := params.Body.SvcToken + ssvc, err := str.FindServiceWithToken(svcToken, tx) if err != nil { logrus.Errorf("error finding service") return service.NewAccessNotFound() } if ssvc == nil { - logrus.Errorf("unable to find service '%v' for user '%v'", params.Body.SvcName, principal.Email) + logrus.Errorf("unable to find service '%v' for user '%v'", svcToken, principal.Email) return service.NewAccessNotFound() } @@ -91,7 +91,7 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode return service.NewAccessInternalServerError() } - return service.NewAccessCreated().WithPayload(&rest_model_zrok.AccessResponse{FrontendName: feToken}) + return service.NewAccessCreated().WithPayload(&rest_model_zrok.AccessResponse{FrontendToken: feToken}) } func createServicePolicyDialForEnvironment(envZId, svcToken, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement, tags ...*rest_model.Tags) error { diff --git a/controller/invite.go b/controller/invite.go index 7e45a592..0249e91d 100644 --- a/controller/invite.go +++ b/controller/invite.go @@ -77,5 +77,5 @@ func (self *inviteHandler) Handle(params account.InviteParams) middleware.Respon logrus.Infof("account request for '%v' has registration token '%v'", params.Body.Email, ar.Token) - return account.NewInviteInternalServerError() + return account.NewInviteCreated() } diff --git a/controller/overview.go b/controller/overview.go index 36e6757f..c7e9c801 100644 --- a/controller/overview.go +++ b/controller/overview.go @@ -54,13 +54,13 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ be = *svc.BackendProxyEndpoint } es.Services = append(es.Services, &rest_model_zrok.Service{ - CreatedAt: svc.CreatedAt.UnixMilli(), - Frontend: fe, - Backend: be, - UpdatedAt: svc.UpdatedAt.UnixMilli(), - ZID: svc.ZId, - Name: svc.Token, - Metrics: sparkData[svc.Token], + CreatedAt: svc.CreatedAt.UnixMilli(), + FrontendEndpoint: fe, + BackendProxyEndpoint: be, + UpdatedAt: svc.UpdatedAt.UnixMilli(), + ZID: svc.ZId, + Token: svc.Token, + Metrics: sparkData[svc.Token], }) } out = append(out, es) diff --git a/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql b/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql index 5c739a09..bca1dcc6 100644 --- a/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql +++ b/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql @@ -24,7 +24,7 @@ create table services ( id serial primary key, environment_id integer not null references environments(id), z_id varchar(32) not null unique, - token varchar(32) not null unique, + token varchar(32) not null unique, share_mode share_mode not null, backend_mode backend_mode not null, frontend_selection varchar(64), @@ -35,7 +35,7 @@ create table services ( updated_at timestamptz not null default(current_timestamp), constraint chk_z_id check (z_id <> ''), - constraint chk_name check (name <> '') + constraint chk_token check (token <> '') ); insert into services (id, environment_id, z_id, token, share_mode, backend_mode, frontend_selection, frontend_endpoint, backend_proxy_endpoint, created_at, updated_at) diff --git a/controller/unaccess.go b/controller/unaccess.go index 896652df..4ce2625b 100644 --- a/controller/unaccess.go +++ b/controller/unaccess.go @@ -17,9 +17,9 @@ func newUnaccessHandler() *unaccessHandler { } func (h *unaccessHandler) Handle(params service.UnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder { - feToken := params.Body.FrontendName - svcToken := params.Body.SvcName - envZId := params.Body.ZID + feToken := params.Body.FrontendToken + svcToken := params.Body.SvcToken + envZId := params.Body.EnvZID logrus.Infof("processing unaccess request for frontend '%v' (service '%v', environment '%v')", feToken, svcToken, envZId) tx, err := str.Begin() @@ -38,13 +38,13 @@ func (h *unaccessHandler) Handle(params service.UnaccessParams, principal *rest_ var senv *store.Environment if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { for _, env := range envs { - if env.ZId == params.Body.ZID { + if env.ZId == envZId { senv = env break } } if senv == nil { - err := errors.Errorf("environment with id '%v' not found for '%v", params.Body.ZID, principal.Email) + err := errors.Errorf("environment with id '%v' not found for '%v", envZId, principal.Email) logrus.Error(err) return service.NewUnaccessUnauthorized() } diff --git a/controller/unshare.go b/controller/unshare.go index c94d0115..7a05c404 100644 --- a/controller/unshare.go +++ b/controller/unshare.go @@ -33,7 +33,7 @@ func (h *unshareHandler) Handle(params service.UnshareParams, principal *rest_mo logrus.Error(err) return service.NewUnshareInternalServerError() } - svcToken := params.Body.SvcName + svcToken := params.Body.SvcToken svcZId, err := h.findServiceZId(svcToken, edge) if err != nil { logrus.Error(err) @@ -42,13 +42,13 @@ func (h *unshareHandler) Handle(params service.UnshareParams, principal *rest_mo var senv *store.Environment if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { for _, env := range envs { - if env.ZId == params.Body.ZID { + if env.ZId == params.Body.EnvZID { senv = env break } } if senv == nil { - err := errors.Errorf("environment with id '%v' not found for '%v", params.Body.ZID, principal.Email) + err := errors.Errorf("environment with id '%v' not found for '%v", params.Body.EnvZID, principal.Email) logrus.Error(err) return service.NewUnshareNotFound() } diff --git a/controller/util.go b/controller/util.go index 6b1db488..5eebd54a 100644 --- a/controller/util.go +++ b/controller/util.go @@ -79,6 +79,6 @@ func realRemoteAddress(req *http.Request) string { return ip } -func proxyUrl(svcName string) string { - return strings.Replace(cfg.Proxy.UrlTemplate, "{svcToken}", svcName, -1) +func proxyUrl(svcToken string) string { + return strings.Replace(cfg.Proxy.UrlTemplate, "{svcToken}", svcToken, -1) } diff --git a/endpoints/private_frontend/config.go b/endpoints/private_frontend/config.go index 7b567486..7d7aea3d 100644 --- a/endpoints/private_frontend/config.go +++ b/endpoints/private_frontend/config.go @@ -2,7 +2,7 @@ package private_frontend type Config struct { IdentityName string - SvcName string + SvcToken string Address string } diff --git a/endpoints/private_frontend/http.go b/endpoints/private_frontend/http.go index ddd47175..317f0ef4 100644 --- a/endpoints/private_frontend/http.go +++ b/endpoints/private_frontend/http.go @@ -19,10 +19,10 @@ import ( ) type httpFrontend struct { - cfg *Config - zCtx ziti.Context - svcName string - handler http.Handler + cfg *Config + zCtx ziti.Context + svcToken string + handler http.Handler } func NewHTTP(cfg *Config) (*httpFrontend, error) { @@ -36,7 +36,7 @@ func NewHTTP(cfg *Config) (*httpFrontend, error) { } zCfg.ConfigTypes = []string{model.ZrokProxyConfig} zCtx := ziti.NewContextWithConfig(zCfg) - zDialCtx := zitiDialContext{ctx: zCtx, svcName: cfg.SvcName} + zDialCtx := zitiDialContext{ctx: zCtx, svcToken: cfg.SvcToken} zTransport := http.DefaultTransport.(*http.Transport).Clone() zTransport.DialContext = zDialCtx.Dial @@ -46,7 +46,7 @@ func NewHTTP(cfg *Config) (*httpFrontend, error) { } proxy.Transport = zTransport - handler := authHandler(cfg.SvcName, util.NewProxyHandler(proxy), "zrok", cfg, zCtx) + handler := authHandler(cfg.SvcToken, util.NewProxyHandler(proxy), "zrok", cfg, zCtx) return &httpFrontend{ cfg: cfg, zCtx: zCtx, @@ -59,12 +59,12 @@ func (h *httpFrontend) Run() error { } type zitiDialContext struct { - ctx ziti.Context - svcName string + ctx ziti.Context + svcToken string } func (zdc *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { - conn, err := zdc.ctx.Dial(zdc.svcName) + conn, err := zdc.ctx.Dial(zdc.svcToken) if err != nil { return conn, err } @@ -90,7 +90,7 @@ func newServiceProxy(cfg *Config, ctx ziti.Context) (*httputil.ReverseProxy, err func serviceTargetProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProxy { director := func(req *http.Request) { - targetSvc := cfg.SvcName + targetSvc := cfg.SvcToken if svc, found := endpoints.GetRefreshedService(targetSvc, ctx); found { if cfg, found := svc.Configs[model.ZrokProxyConfig]; found { logrus.Debugf("auth model: %v", cfg) @@ -121,19 +121,19 @@ func serviceTargetProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProxy { return &httputil.ReverseProxy{Director: director} } -func authHandler(svcName string, handler http.Handler, realm string, cfg *Config, ctx ziti.Context) http.HandlerFunc { +func authHandler(svcToken string, handler http.Handler, realm string, cfg *Config, ctx ziti.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - if svc, found := endpoints.GetRefreshedService(svcName, ctx); found { + if svc, found := endpoints.GetRefreshedService(svcToken, ctx); found { if cfg, found := svc.Configs[model.ZrokProxyConfig]; found { if scheme, found := cfg["auth_scheme"]; found { switch scheme { case string(model.None): - logrus.Debugf("auth scheme none '%v'", svcName) + logrus.Debugf("auth scheme none '%v'", svcToken) handler.ServeHTTP(w, r) return case string(model.Basic): - logrus.Debugf("auth scheme basic '%v", svcName) + logrus.Debugf("auth scheme basic '%v", svcToken) inUser, inPass, ok := r.BasicAuth() if !ok { writeUnauthorizedResponse(w, realm) @@ -182,15 +182,15 @@ func authHandler(svcName string, handler http.Handler, realm string, cfg *Config return } } else { - logrus.Warnf("%v -> no auth scheme for '%v'", r.RemoteAddr, svcName) + logrus.Warnf("%v -> no auth scheme for '%v'", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } else { - logrus.Warnf("%v -> no proxy config for '%v'", r.RemoteAddr, svcName) + logrus.Warnf("%v -> no proxy config for '%v'", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } else { - logrus.Warnf("%v -> service '%v' not found", r.RemoteAddr, svcName) + logrus.Warnf("%v -> service '%v' not found", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } diff --git a/endpoints/public_frontend/http.go b/endpoints/public_frontend/http.go index b31209cf..4e05b1d6 100644 --- a/endpoints/public_frontend/http.go +++ b/endpoints/public_frontend/http.go @@ -73,12 +73,12 @@ type zitiDialContext struct { } func (self *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { - svcName := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port') - conn, err := self.ctx.Dial(svcName) + svcToken := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port') + conn, err := self.ctx.Dial(svcToken) if err != nil { return conn, err } - return newMetricsConn(svcName, conn, self.updates), nil + return newMetricsConn(svcToken, conn, self.updates), nil } func newServiceProxy(cfg *Config, ctx ziti.Context) (*httputil.ReverseProxy, error) { @@ -133,19 +133,19 @@ func hostTargetReverseProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProx func authHandler(handler http.Handler, realm string, cfg *Config, ctx ziti.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - svcName := resolveService(cfg.HostMatch, r.Host) - if svcName != "" { - if svc, found := endpoints.GetRefreshedService(svcName, ctx); found { + svcToken := resolveService(cfg.HostMatch, r.Host) + if svcToken != "" { + if svc, found := endpoints.GetRefreshedService(svcToken, ctx); found { if cfg, found := svc.Configs[model.ZrokProxyConfig]; found { if scheme, found := cfg["auth_scheme"]; found { switch scheme { case string(model.None): - logrus.Debugf("auth scheme none '%v'", svcName) + logrus.Debugf("auth scheme none '%v'", svcToken) handler.ServeHTTP(w, r) return case string(model.Basic): - logrus.Debugf("auth scheme basic '%v", svcName) + logrus.Debugf("auth scheme basic '%v", svcToken) inUser, inPass, ok := r.BasicAuth() if !ok { writeUnauthorizedResponse(w, realm) @@ -194,15 +194,15 @@ func authHandler(handler http.Handler, realm string, cfg *Config, ctx ziti.Conte return } } else { - logrus.Warnf("%v -> no auth scheme for '%v'", r.RemoteAddr, svcName) + logrus.Warnf("%v -> no auth scheme for '%v'", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } else { - logrus.Warnf("%v -> no proxy config for '%v'", r.RemoteAddr, svcName) + logrus.Warnf("%v -> no proxy config for '%v'", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } else { - logrus.Warnf("%v -> service '%v' not found", r.RemoteAddr, svcName) + logrus.Warnf("%v -> service '%v' not found", r.RemoteAddr, svcToken) notfound_ui.WriteNotFound(w) } } else { diff --git a/rest_model_zrok/access_request.go b/rest_model_zrok/access_request.go index 861f4b33..8e5f18db 100644 --- a/rest_model_zrok/access_request.go +++ b/rest_model_zrok/access_request.go @@ -17,11 +17,11 @@ import ( // swagger:model accessRequest type AccessRequest struct { - // svc name - SvcName string `json:"svcName,omitempty"` + // env z Id + EnvZID string `json:"envZId,omitempty"` - // z Id - ZID string `json:"zId,omitempty"` + // svc token + SvcToken string `json:"svcToken,omitempty"` } // Validate validates this access request diff --git a/rest_model_zrok/access_response.go b/rest_model_zrok/access_response.go index 2cd056b5..f4b0e679 100644 --- a/rest_model_zrok/access_response.go +++ b/rest_model_zrok/access_response.go @@ -17,8 +17,8 @@ import ( // swagger:model accessResponse type AccessResponse struct { - // frontend name - FrontendName string `json:"frontendName,omitempty"` + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` } // Validate validates this access response diff --git a/rest_model_zrok/service.go b/rest_model_zrok/service.go index 70e4fc7c..c56de2f8 100644 --- a/rest_model_zrok/service.go +++ b/rest_model_zrok/service.go @@ -18,20 +18,20 @@ import ( // swagger:model service type Service struct { - // backend - Backend string `json:"backend,omitempty"` + // backend proxy endpoint + BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"` // created at CreatedAt int64 `json:"createdAt,omitempty"` - // frontend - Frontend string `json:"frontend,omitempty"` + // frontend endpoint + FrontendEndpoint string `json:"frontendEndpoint,omitempty"` // metrics Metrics ServiceMetrics `json:"metrics,omitempty"` - // name - Name string `json:"name,omitempty"` + // token + Token string `json:"token,omitempty"` // updated at UpdatedAt int64 `json:"updatedAt,omitempty"` diff --git a/rest_model_zrok/unaccess_request.go b/rest_model_zrok/unaccess_request.go index 27536aa0..10d6be41 100644 --- a/rest_model_zrok/unaccess_request.go +++ b/rest_model_zrok/unaccess_request.go @@ -17,14 +17,14 @@ import ( // swagger:model unaccessRequest type UnaccessRequest struct { - // frontend name - FrontendName string `json:"frontendName,omitempty"` + // env z Id + EnvZID string `json:"envZId,omitempty"` - // svc name - SvcName string `json:"svcName,omitempty"` + // frontend token + FrontendToken string `json:"frontendToken,omitempty"` - // z Id - ZID string `json:"zId,omitempty"` + // svc token + SvcToken string `json:"svcToken,omitempty"` } // Validate validates this unaccess request diff --git a/rest_model_zrok/unshare_request.go b/rest_model_zrok/unshare_request.go index 779743da..5faae0f5 100644 --- a/rest_model_zrok/unshare_request.go +++ b/rest_model_zrok/unshare_request.go @@ -17,11 +17,11 @@ import ( // swagger:model unshareRequest type UnshareRequest struct { - // svc name - SvcName string `json:"svcName,omitempty"` + // env z Id + EnvZID string `json:"envZId,omitempty"` - // z Id - ZID string `json:"zId,omitempty"` + // svc token + SvcToken string `json:"svcToken,omitempty"` } // Validate validates this unshare request diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index a5daf5c9..b66dd524 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -465,10 +465,10 @@ func init() { "accessRequest": { "type": "object", "properties": { - "svcName": { + "envZId": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } @@ -476,7 +476,7 @@ func init() { "accessResponse": { "type": "object", "properties": { - "frontendName": { + "frontendToken": { "type": "string" } } @@ -632,19 +632,19 @@ func init() { "service": { "type": "object", "properties": { - "backend": { + "backendProxyEndpoint": { "type": "string" }, "createdAt": { "type": "integer" }, - "frontend": { + "frontendEndpoint": { "type": "string" }, "metrics": { "$ref": "#/definitions/serviceMetrics" }, - "name": { + "token": { "type": "string" }, "updatedAt": { @@ -759,13 +759,13 @@ func init() { "unaccessRequest": { "type": "object", "properties": { - "frontendName": { + "envZId": { "type": "string" }, - "svcName": { + "frontendToken": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } @@ -773,10 +773,10 @@ func init() { "unshareRequest": { "type": "object", "properties": { - "svcName": { + "envZId": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } @@ -1257,10 +1257,10 @@ func init() { "accessRequest": { "type": "object", "properties": { - "svcName": { + "envZId": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } @@ -1268,7 +1268,7 @@ func init() { "accessResponse": { "type": "object", "properties": { - "frontendName": { + "frontendToken": { "type": "string" } } @@ -1424,19 +1424,19 @@ func init() { "service": { "type": "object", "properties": { - "backend": { + "backendProxyEndpoint": { "type": "string" }, "createdAt": { "type": "integer" }, - "frontend": { + "frontendEndpoint": { "type": "string" }, "metrics": { "$ref": "#/definitions/serviceMetrics" }, - "name": { + "token": { "type": "string" }, "updatedAt": { @@ -1551,13 +1551,13 @@ func init() { "unaccessRequest": { "type": "object", "properties": { - "frontendName": { + "envZId": { "type": "string" }, - "svcName": { + "frontendToken": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } @@ -1565,10 +1565,10 @@ func init() { "unshareRequest": { "type": "object", "properties": { - "svcName": { + "envZId": { "type": "string" }, - "zId": { + "svcToken": { "type": "string" } } diff --git a/specs/zrok.yml b/specs/zrok.yml index a5c45e43..11540624 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -293,15 +293,15 @@ definitions: accessRequest: type: object properties: - zId: + envZId: type: string - svcName: + svcToken: type: string accessResponse: type: object properties: - frontendName: + frontendToken: type: string authUser: @@ -439,11 +439,11 @@ definitions: properties: zId: type: string - name: + token: type: string - frontend: + frontendEndpoint: type: string - backend: + backendProxyEndpoint: type: string metrics: $ref: "#/definitions/serviceMetrics" @@ -503,19 +503,19 @@ definitions: unaccessRequest: type: object properties: - frontendName: + frontendToken: type: string - zId: + envZId: type: string - svcName: + svcToken: type: string unshareRequest: type: object properties: - zId: + envZId: type: string - svcName: + svcToken: type: string verifyRequest: diff --git a/ui/src/Account.js b/ui/src/Account.js index 150e710b..687db2ca 100644 --- a/ui/src/Account.js +++ b/ui/src/Account.js @@ -87,7 +87,7 @@ function buildGraph(overview) { item.services.forEach((item) => { out.nodes.push({ id: '' + id, - data: {label:
{ item.name }
}, + data: {label:
{ item.token }
}, position: {x: (id * 25), y: 0}, style: { width: 'fit-content', backgroundColor: '#9367ef', color: 'white' }, type: 'output', diff --git a/ui/src/Environments.js b/ui/src/Environments.js index 96e70f59..4d53cda6 100644 --- a/ui/src/Environments.js +++ b/ui/src/Environments.js @@ -2,14 +2,14 @@ import DataTable from 'react-data-table-component'; import Services from './Services'; import Icon from "@mdi/react"; import {mdiCloseOutline} from "@mdi/js"; -import * as identity from './api/identity'; +import * as environment from './api/environment'; const Environments = (props) => { const humanizeDuration = require("humanize-duration") const disableEnvironment = (envId) => { console.log(envId) if(window.confirm('really disable environment "' + envId +'"?')) { - identity.disable({body: {identity: envId}}).then(resp => { + environment.disable({body: {identity: envId}}).then(resp => { console.log(resp); }) } diff --git a/ui/src/Login.js b/ui/src/Login.js index 01ef2e18..585c3225 100644 --- a/ui/src/Login.js +++ b/ui/src/Login.js @@ -1,5 +1,5 @@ import {useState} from "react"; -import * as identity from './api/identity'; +import * as account from './api/account'; const Login = (props) => { const [email, setEmail] = useState(''); @@ -11,7 +11,7 @@ const Login = (props) => { const handleSubmit = async e => { e.preventDefault() - identity.login({body: {"email": email, "password": password}}) + account.login({body: {"email": email, "password": password}}) .then(resp => { if (!resp.error) { let user = { diff --git a/ui/src/Register.js b/ui/src/Register.js index 782fd321..aea54966 100644 --- a/ui/src/Register.js +++ b/ui/src/Register.js @@ -2,7 +2,7 @@ import Icon from "@mdi/react"; import { useParams } from 'react-router-dom'; import {useEffect, useState} from "react"; import {mdiContentCopy} from "@mdi/js"; -import * as identity from "./api/identity"; +import * as account from "./api/account"; const RegistrationForm = (props) => { const [password, setPassword] = useState(''); @@ -20,7 +20,7 @@ const RegistrationForm = (props) => { if(confirm !== password) { setMessage(passwordMismatchMessage); } else { - identity.register({body: {"token": props.token, "password": password}}) + account.register({body: {"token": props.token, "password": password}}) .then(resp => { if(!resp.error) { console.log("resp", resp) @@ -110,7 +110,7 @@ const Register = () => { useEffect(() => { let mounted = true - identity.verify({body: {token: token}}).then(resp => { + account.verify({body: {token: token}}).then(resp => { if(mounted) { if(resp.error) { setActiveRequest(false); diff --git a/ui/src/Services.js b/ui/src/Services.js index 542307d9..8a123627 100644 --- a/ui/src/Services.js +++ b/ui/src/Services.js @@ -6,9 +6,9 @@ import * as service from './api/service'; const Services = (props) => { const humanizeDuration = require("humanize-duration") - const unshareService = (envId, svcName) => { - if(window.confirm('really disable service "' + svcName +'"?')) { - service.unshare({body: {zId: envId, svcName: svcName}}).then(resp => { + const unshareService = (envId, svcToken) => { + if(window.confirm('really disable service "' + svcToken +'"?')) { + service.unshare({body: {zId: envId, svcToken: svcToken}}).then(resp => { console.log(resp) }) } @@ -17,12 +17,12 @@ const Services = (props) => { const columns = [ { name: 'Frontend', - selector: row => row.frontend, + selector: row => row.frontendEndpoint, sortable: true, }, { name: 'Backend', - selector: row => row.backend, + selector: row => row.backendProxyEndpoint, sortable: true, }, { diff --git a/ui/src/api/types.js b/ui/src/api/types.js index fc67e16d..f744a02c 100644 --- a/ui/src/api/types.js +++ b/ui/src/api/types.js @@ -5,15 +5,15 @@ * @typedef accessRequest * @memberof module:types * - * @property {string} zId - * @property {string} svcName + * @property {string} envZId + * @property {string} svcToken */ /** * @typedef accessResponse * @memberof module:types * - * @property {string} frontendName + * @property {string} frontendToken */ /** @@ -126,9 +126,9 @@ * @memberof module:types * * @property {string} zId - * @property {string} name - * @property {string} frontend - * @property {string} backend + * @property {string} token + * @property {string} frontendEndpoint + * @property {string} backendProxyEndpoint * @property {module:types.serviceMetrics} metrics * @property {number} createdAt * @property {number} updatedAt @@ -166,17 +166,17 @@ * @typedef unaccessRequest * @memberof module:types * - * @property {string} frontendName - * @property {string} zId - * @property {string} svcName + * @property {string} frontendToken + * @property {string} envZId + * @property {string} svcToken */ /** * @typedef unshareRequest * @memberof module:types * - * @property {string} zId - * @property {string} svcName + * @property {string} envZId + * @property {string} svcToken */ /**