more naming refactoring 'name' -> 'token' (#119)

This commit is contained in:
Michael Quigley 2022-11-30 12:46:19 -05:00
parent 483babe813
commit f9143c3a5b
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
28 changed files with 152 additions and 152 deletions

View File

@ -38,7 +38,7 @@ func newAccessPrivateCommand() *accessPrivateCommand {
} }
func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) { func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
svcName := args[0] svcToken := args[0]
endpointUrl, err := url.Parse("http://" + cmd.bindAddress) endpointUrl, err := url.Parse("http://" + cmd.bindAddress)
if err != nil { if err != nil {
@ -66,8 +66,8 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token) auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token)
req := service.NewAccessParams() req := service.NewAccessParams()
req.Body = &rest_model_zrok.AccessRequest{ req.Body = &rest_model_zrok.AccessRequest{
SvcName: svcName, SvcToken: svcToken,
ZID: env.ZId, EnvZID: env.ZId,
} }
accessResp, err := zrok.Service.Access(req, auth) accessResp, err := zrok.Service.Access(req, auth)
if err != nil { if err != nil {
@ -76,17 +76,17 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
} }
panic(err) panic(err)
} }
logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendName) logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendToken)
cfg := private_frontend.DefaultConfig("backend") cfg := private_frontend.DefaultConfig("backend")
cfg.SvcName = svcName cfg.SvcToken = svcToken
cfg.Address = cmd.bindAddress cfg.Address = cmd.bindAddress
c := make(chan os.Signal) c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM) signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() { go func() {
<-c <-c
cmd.destroy(accessResp.Payload.FrontendName, env.ZId, svcName, zrok, auth) cmd.destroy(accessResp.Payload.FrontendToken, env.ZId, svcToken, zrok, auth)
os.Exit(0) 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) { func (cmd *accessPrivateCommand) destroy(frotendName, envZId, svcToken string, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {
logrus.Debugf("shutting down '%v'", svcName) logrus.Debugf("shutting down '%v'", svcToken)
req := service.NewUnaccessParams() req := service.NewUnaccessParams()
req.Body = &rest_model_zrok.UnaccessRequest{ req.Body = &rest_model_zrok.UnaccessRequest{
FrontendName: frotendName, FrontendToken: frotendName,
SvcName: svcName, SvcToken: svcToken,
ZID: envZId, EnvZID: envZId,
} }
if _, err := zrok.Service.Unaccess(req, auth); err == nil { if _, err := zrok.Service.Unaccess(req, auth); err == nil {
logrus.Debugf("shutdown complete") logrus.Debugf("shutdown complete")

View File

@ -259,8 +259,8 @@ func (l *looper) shutdown() {
untunnelReq := service.NewUnshareParams() untunnelReq := service.NewUnshareParams()
untunnelReq.Body = &rest_model_zrok.UnshareRequest{ untunnelReq.Body = &rest_model_zrok.UnshareRequest{
ZID: l.env.ZId, EnvZID: l.env.ZId,
SvcName: l.service, SvcToken: l.service,
} }
if _, err := l.zrok.Service.Unshare(untunnelReq, l.auth); err != nil { if _, err := l.zrok.Service.Unshare(untunnelReq, l.auth); err != nil {
logrus.Errorf("error shutting down looper #%d: %v", l.id, err) logrus.Errorf("error shutting down looper #%d: %v", l.id, err)

View File

@ -115,8 +115,8 @@ func (self *shareAgainCommand) destroy(id string, cfg *backend.Config, zrok *res
logrus.Debugf("shutting down '%v'", cfg.Service) logrus.Debugf("shutting down '%v'", cfg.Service)
req := service.NewUnshareParams() req := service.NewUnshareParams()
req.Body = &rest_model_zrok.UnshareRequest{ req.Body = &rest_model_zrok.UnshareRequest{
ZID: id, EnvZID: id,
SvcName: cfg.Service, SvcToken: cfg.Service,
} }
if _, err := zrok.Service.Unshare(req, auth); err == nil { if _, err := zrok.Service.Unshare(req, auth); err == nil {
logrus.Debugf("shutdown complete") logrus.Debugf("shutdown complete")

View File

@ -149,8 +149,8 @@ func (self *sharePrivateCommand) destroy(id string, cfg *backend.Config, zrok *r
logrus.Debugf("shutting down '%v'", cfg.Service) logrus.Debugf("shutting down '%v'", cfg.Service)
req := service.NewUnshareParams() req := service.NewUnshareParams()
req.Body = &rest_model_zrok.UnshareRequest{ req.Body = &rest_model_zrok.UnshareRequest{
ZID: id, EnvZID: id,
SvcName: cfg.Service, SvcToken: cfg.Service,
} }
if _, err := zrok.Service.Unshare(req, auth); err == nil { if _, err := zrok.Service.Unshare(req, auth); err == nil {
logrus.Debugf("shutdown complete") logrus.Debugf("shutdown complete")

View File

@ -228,8 +228,8 @@ func (self *sharePublicCommand) destroy(id string, cfg *backend.Config, zrok *re
logrus.Debugf("shutting down '%v'", cfg.Service) logrus.Debugf("shutting down '%v'", cfg.Service)
req := service.NewUnshareParams() req := service.NewUnshareParams()
req.Body = &rest_model_zrok.UnshareRequest{ req.Body = &rest_model_zrok.UnshareRequest{
ZID: id, EnvZID: id,
SvcName: cfg.Service, SvcToken: cfg.Service,
} }
if _, err := zrok.Service.Unshare(req, auth); err == nil { if _, err := zrok.Service.Unshare(req, auth); err == nil {
logrus.Debugf("shutdown complete") logrus.Debugf("shutdown complete")

View File

@ -29,7 +29,7 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode
} }
defer func() { _ = tx.Rollback() }() defer func() { _ = tx.Rollback() }()
envZId := params.Body.ZID envZId := params.Body.EnvZID
envId := 0 envId := 0
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
found := false found := false
@ -50,14 +50,14 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode
return service.NewAccessNotFound() return service.NewAccessNotFound()
} }
svcName := params.Body.SvcName svcToken := params.Body.SvcToken
ssvc, err := str.FindServiceWithToken(svcName, tx) ssvc, err := str.FindServiceWithToken(svcToken, tx)
if err != nil { if err != nil {
logrus.Errorf("error finding service") logrus.Errorf("error finding service")
return service.NewAccessNotFound() return service.NewAccessNotFound()
} }
if ssvc == nil { 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() return service.NewAccessNotFound()
} }
@ -91,7 +91,7 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode
return service.NewAccessInternalServerError() 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 { func createServicePolicyDialForEnvironment(envZId, svcToken, svcZId string, edge *rest_management_api_client.ZitiEdgeManagement, tags ...*rest_model.Tags) error {

View File

@ -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) logrus.Infof("account request for '%v' has registration token '%v'", params.Body.Email, ar.Token)
return account.NewInviteInternalServerError() return account.NewInviteCreated()
} }

View File

@ -55,11 +55,11 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
} }
es.Services = append(es.Services, &rest_model_zrok.Service{ es.Services = append(es.Services, &rest_model_zrok.Service{
CreatedAt: svc.CreatedAt.UnixMilli(), CreatedAt: svc.CreatedAt.UnixMilli(),
Frontend: fe, FrontendEndpoint: fe,
Backend: be, BackendProxyEndpoint: be,
UpdatedAt: svc.UpdatedAt.UnixMilli(), UpdatedAt: svc.UpdatedAt.UnixMilli(),
ZID: svc.ZId, ZID: svc.ZId,
Name: svc.Token, Token: svc.Token,
Metrics: sparkData[svc.Token], Metrics: sparkData[svc.Token],
}) })
} }

View File

@ -35,7 +35,7 @@ create table services (
updated_at timestamptz not null default(current_timestamp), updated_at timestamptz not null default(current_timestamp),
constraint chk_z_id check (z_id <> ''), 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) insert into services (id, environment_id, z_id, token, share_mode, backend_mode, frontend_selection, frontend_endpoint, backend_proxy_endpoint, created_at, updated_at)

View File

@ -17,9 +17,9 @@ func newUnaccessHandler() *unaccessHandler {
} }
func (h *unaccessHandler) Handle(params service.UnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder { func (h *unaccessHandler) Handle(params service.UnaccessParams, principal *rest_model_zrok.Principal) middleware.Responder {
feToken := params.Body.FrontendName feToken := params.Body.FrontendToken
svcToken := params.Body.SvcName svcToken := params.Body.SvcToken
envZId := params.Body.ZID envZId := params.Body.EnvZID
logrus.Infof("processing unaccess request for frontend '%v' (service '%v', environment '%v')", feToken, svcToken, envZId) logrus.Infof("processing unaccess request for frontend '%v' (service '%v', environment '%v')", feToken, svcToken, envZId)
tx, err := str.Begin() tx, err := str.Begin()
@ -38,13 +38,13 @@ func (h *unaccessHandler) Handle(params service.UnaccessParams, principal *rest_
var senv *store.Environment var senv *store.Environment
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
for _, env := range envs { for _, env := range envs {
if env.ZId == params.Body.ZID { if env.ZId == envZId {
senv = env senv = env
break break
} }
} }
if senv == nil { 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) logrus.Error(err)
return service.NewUnaccessUnauthorized() return service.NewUnaccessUnauthorized()
} }

View File

@ -33,7 +33,7 @@ func (h *unshareHandler) Handle(params service.UnshareParams, principal *rest_mo
logrus.Error(err) logrus.Error(err)
return service.NewUnshareInternalServerError() return service.NewUnshareInternalServerError()
} }
svcToken := params.Body.SvcName svcToken := params.Body.SvcToken
svcZId, err := h.findServiceZId(svcToken, edge) svcZId, err := h.findServiceZId(svcToken, edge)
if err != nil { if err != nil {
logrus.Error(err) logrus.Error(err)
@ -42,13 +42,13 @@ func (h *unshareHandler) Handle(params service.UnshareParams, principal *rest_mo
var senv *store.Environment var senv *store.Environment
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil { if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
for _, env := range envs { for _, env := range envs {
if env.ZId == params.Body.ZID { if env.ZId == params.Body.EnvZID {
senv = env senv = env
break break
} }
} }
if senv == nil { 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) logrus.Error(err)
return service.NewUnshareNotFound() return service.NewUnshareNotFound()
} }

View File

@ -79,6 +79,6 @@ func realRemoteAddress(req *http.Request) string {
return ip return ip
} }
func proxyUrl(svcName string) string { func proxyUrl(svcToken string) string {
return strings.Replace(cfg.Proxy.UrlTemplate, "{svcToken}", svcName, -1) return strings.Replace(cfg.Proxy.UrlTemplate, "{svcToken}", svcToken, -1)
} }

View File

@ -2,7 +2,7 @@ package private_frontend
type Config struct { type Config struct {
IdentityName string IdentityName string
SvcName string SvcToken string
Address string Address string
} }

View File

@ -21,7 +21,7 @@ import (
type httpFrontend struct { type httpFrontend struct {
cfg *Config cfg *Config
zCtx ziti.Context zCtx ziti.Context
svcName string svcToken string
handler http.Handler handler http.Handler
} }
@ -36,7 +36,7 @@ func NewHTTP(cfg *Config) (*httpFrontend, error) {
} }
zCfg.ConfigTypes = []string{model.ZrokProxyConfig} zCfg.ConfigTypes = []string{model.ZrokProxyConfig}
zCtx := ziti.NewContextWithConfig(zCfg) 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 := http.DefaultTransport.(*http.Transport).Clone()
zTransport.DialContext = zDialCtx.Dial zTransport.DialContext = zDialCtx.Dial
@ -46,7 +46,7 @@ func NewHTTP(cfg *Config) (*httpFrontend, error) {
} }
proxy.Transport = zTransport 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{ return &httpFrontend{
cfg: cfg, cfg: cfg,
zCtx: zCtx, zCtx: zCtx,
@ -60,11 +60,11 @@ func (h *httpFrontend) Run() error {
type zitiDialContext struct { type zitiDialContext struct {
ctx ziti.Context ctx ziti.Context
svcName string svcToken string
} }
func (zdc *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { 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 { if err != nil {
return conn, err 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 { func serviceTargetProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProxy {
director := func(req *http.Request) { director := func(req *http.Request) {
targetSvc := cfg.SvcName targetSvc := cfg.SvcToken
if svc, found := endpoints.GetRefreshedService(targetSvc, ctx); found { if svc, found := endpoints.GetRefreshedService(targetSvc, ctx); found {
if cfg, found := svc.Configs[model.ZrokProxyConfig]; found { if cfg, found := svc.Configs[model.ZrokProxyConfig]; found {
logrus.Debugf("auth model: %v", cfg) logrus.Debugf("auth model: %v", cfg)
@ -121,19 +121,19 @@ func serviceTargetProxy(cfg *Config, ctx ziti.Context) *httputil.ReverseProxy {
return &httputil.ReverseProxy{Director: director} 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) { 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 cfg, found := svc.Configs[model.ZrokProxyConfig]; found {
if scheme, found := cfg["auth_scheme"]; found { if scheme, found := cfg["auth_scheme"]; found {
switch scheme { switch scheme {
case string(model.None): case string(model.None):
logrus.Debugf("auth scheme none '%v'", svcName) logrus.Debugf("auth scheme none '%v'", svcToken)
handler.ServeHTTP(w, r) handler.ServeHTTP(w, r)
return return
case string(model.Basic): case string(model.Basic):
logrus.Debugf("auth scheme basic '%v", svcName) logrus.Debugf("auth scheme basic '%v", svcToken)
inUser, inPass, ok := r.BasicAuth() inUser, inPass, ok := r.BasicAuth()
if !ok { if !ok {
writeUnauthorizedResponse(w, realm) writeUnauthorizedResponse(w, realm)
@ -182,15 +182,15 @@ func authHandler(svcName string, handler http.Handler, realm string, cfg *Config
return return
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} }

View File

@ -73,12 +73,12 @@ type zitiDialContext struct {
} }
func (self *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) { func (self *zitiDialContext) Dial(_ context.Context, _ string, addr string) (net.Conn, error) {
svcName := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port') svcToken := strings.Split(addr, ":")[0] // ignore :port (we get passed 'host:port')
conn, err := self.ctx.Dial(svcName) conn, err := self.ctx.Dial(svcToken)
if err != nil { if err != nil {
return conn, err 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) { 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 { func authHandler(handler http.Handler, realm string, cfg *Config, ctx ziti.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
svcName := resolveService(cfg.HostMatch, r.Host) svcToken := resolveService(cfg.HostMatch, r.Host)
if svcName != "" { if svcToken != "" {
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 cfg, found := svc.Configs[model.ZrokProxyConfig]; found {
if scheme, found := cfg["auth_scheme"]; found { if scheme, found := cfg["auth_scheme"]; found {
switch scheme { switch scheme {
case string(model.None): case string(model.None):
logrus.Debugf("auth scheme none '%v'", svcName) logrus.Debugf("auth scheme none '%v'", svcToken)
handler.ServeHTTP(w, r) handler.ServeHTTP(w, r)
return return
case string(model.Basic): case string(model.Basic):
logrus.Debugf("auth scheme basic '%v", svcName) logrus.Debugf("auth scheme basic '%v", svcToken)
inUser, inPass, ok := r.BasicAuth() inUser, inPass, ok := r.BasicAuth()
if !ok { if !ok {
writeUnauthorizedResponse(w, realm) writeUnauthorizedResponse(w, realm)
@ -194,15 +194,15 @@ func authHandler(handler http.Handler, realm string, cfg *Config, ctx ziti.Conte
return return
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} else { } 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) notfound_ui.WriteNotFound(w)
} }
} else { } else {

View File

@ -17,11 +17,11 @@ import (
// swagger:model accessRequest // swagger:model accessRequest
type AccessRequest struct { type AccessRequest struct {
// svc name // env z Id
SvcName string `json:"svcName,omitempty"` EnvZID string `json:"envZId,omitempty"`
// z Id // svc token
ZID string `json:"zId,omitempty"` SvcToken string `json:"svcToken,omitempty"`
} }
// Validate validates this access request // Validate validates this access request

View File

@ -17,8 +17,8 @@ import (
// swagger:model accessResponse // swagger:model accessResponse
type AccessResponse struct { type AccessResponse struct {
// frontend name // frontend token
FrontendName string `json:"frontendName,omitempty"` FrontendToken string `json:"frontendToken,omitempty"`
} }
// Validate validates this access response // Validate validates this access response

View File

@ -18,20 +18,20 @@ import (
// swagger:model service // swagger:model service
type Service struct { type Service struct {
// backend // backend proxy endpoint
Backend string `json:"backend,omitempty"` BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"`
// created at // created at
CreatedAt int64 `json:"createdAt,omitempty"` CreatedAt int64 `json:"createdAt,omitempty"`
// frontend // frontend endpoint
Frontend string `json:"frontend,omitempty"` FrontendEndpoint string `json:"frontendEndpoint,omitempty"`
// metrics // metrics
Metrics ServiceMetrics `json:"metrics,omitempty"` Metrics ServiceMetrics `json:"metrics,omitempty"`
// name // token
Name string `json:"name,omitempty"` Token string `json:"token,omitempty"`
// updated at // updated at
UpdatedAt int64 `json:"updatedAt,omitempty"` UpdatedAt int64 `json:"updatedAt,omitempty"`

View File

@ -17,14 +17,14 @@ import (
// swagger:model unaccessRequest // swagger:model unaccessRequest
type UnaccessRequest struct { type UnaccessRequest struct {
// frontend name // env z Id
FrontendName string `json:"frontendName,omitempty"` EnvZID string `json:"envZId,omitempty"`
// svc name // frontend token
SvcName string `json:"svcName,omitempty"` FrontendToken string `json:"frontendToken,omitempty"`
// z Id // svc token
ZID string `json:"zId,omitempty"` SvcToken string `json:"svcToken,omitempty"`
} }
// Validate validates this unaccess request // Validate validates this unaccess request

View File

@ -17,11 +17,11 @@ import (
// swagger:model unshareRequest // swagger:model unshareRequest
type UnshareRequest struct { type UnshareRequest struct {
// svc name // env z Id
SvcName string `json:"svcName,omitempty"` EnvZID string `json:"envZId,omitempty"`
// z Id // svc token
ZID string `json:"zId,omitempty"` SvcToken string `json:"svcToken,omitempty"`
} }
// Validate validates this unshare request // Validate validates this unshare request

View File

@ -465,10 +465,10 @@ func init() {
"accessRequest": { "accessRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"svcName": { "envZId": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }
@ -476,7 +476,7 @@ func init() {
"accessResponse": { "accessResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"frontendName": { "frontendToken": {
"type": "string" "type": "string"
} }
} }
@ -632,19 +632,19 @@ func init() {
"service": { "service": {
"type": "object", "type": "object",
"properties": { "properties": {
"backend": { "backendProxyEndpoint": {
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"type": "integer" "type": "integer"
}, },
"frontend": { "frontendEndpoint": {
"type": "string" "type": "string"
}, },
"metrics": { "metrics": {
"$ref": "#/definitions/serviceMetrics" "$ref": "#/definitions/serviceMetrics"
}, },
"name": { "token": {
"type": "string" "type": "string"
}, },
"updatedAt": { "updatedAt": {
@ -759,13 +759,13 @@ func init() {
"unaccessRequest": { "unaccessRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"frontendName": { "envZId": {
"type": "string" "type": "string"
}, },
"svcName": { "frontendToken": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }
@ -773,10 +773,10 @@ func init() {
"unshareRequest": { "unshareRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"svcName": { "envZId": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }
@ -1257,10 +1257,10 @@ func init() {
"accessRequest": { "accessRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"svcName": { "envZId": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }
@ -1268,7 +1268,7 @@ func init() {
"accessResponse": { "accessResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"frontendName": { "frontendToken": {
"type": "string" "type": "string"
} }
} }
@ -1424,19 +1424,19 @@ func init() {
"service": { "service": {
"type": "object", "type": "object",
"properties": { "properties": {
"backend": { "backendProxyEndpoint": {
"type": "string" "type": "string"
}, },
"createdAt": { "createdAt": {
"type": "integer" "type": "integer"
}, },
"frontend": { "frontendEndpoint": {
"type": "string" "type": "string"
}, },
"metrics": { "metrics": {
"$ref": "#/definitions/serviceMetrics" "$ref": "#/definitions/serviceMetrics"
}, },
"name": { "token": {
"type": "string" "type": "string"
}, },
"updatedAt": { "updatedAt": {
@ -1551,13 +1551,13 @@ func init() {
"unaccessRequest": { "unaccessRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"frontendName": { "envZId": {
"type": "string" "type": "string"
}, },
"svcName": { "frontendToken": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }
@ -1565,10 +1565,10 @@ func init() {
"unshareRequest": { "unshareRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"svcName": { "envZId": {
"type": "string" "type": "string"
}, },
"zId": { "svcToken": {
"type": "string" "type": "string"
} }
} }

View File

@ -293,15 +293,15 @@ definitions:
accessRequest: accessRequest:
type: object type: object
properties: properties:
zId: envZId:
type: string type: string
svcName: svcToken:
type: string type: string
accessResponse: accessResponse:
type: object type: object
properties: properties:
frontendName: frontendToken:
type: string type: string
authUser: authUser:
@ -439,11 +439,11 @@ definitions:
properties: properties:
zId: zId:
type: string type: string
name: token:
type: string type: string
frontend: frontendEndpoint:
type: string type: string
backend: backendProxyEndpoint:
type: string type: string
metrics: metrics:
$ref: "#/definitions/serviceMetrics" $ref: "#/definitions/serviceMetrics"
@ -503,19 +503,19 @@ definitions:
unaccessRequest: unaccessRequest:
type: object type: object
properties: properties:
frontendName: frontendToken:
type: string type: string
zId: envZId:
type: string type: string
svcName: svcToken:
type: string type: string
unshareRequest: unshareRequest:
type: object type: object
properties: properties:
zId: envZId:
type: string type: string
svcName: svcToken:
type: string type: string
verifyRequest: verifyRequest:

View File

@ -87,7 +87,7 @@ function buildGraph(overview) {
item.services.forEach((item) => { item.services.forEach((item) => {
out.nodes.push({ out.nodes.push({
id: '' + id, id: '' + id,
data: {label: <div><Icon path={mdiAccessPointNetwork} size={0.75} className={"flowNode"}/> { item.name }</div>}, data: {label: <div><Icon path={mdiAccessPointNetwork} size={0.75} className={"flowNode"}/> { item.token }</div>},
position: {x: (id * 25), y: 0}, position: {x: (id * 25), y: 0},
style: { width: 'fit-content', backgroundColor: '#9367ef', color: 'white' }, style: { width: 'fit-content', backgroundColor: '#9367ef', color: 'white' },
type: 'output', type: 'output',

View File

@ -2,14 +2,14 @@ import DataTable from 'react-data-table-component';
import Services from './Services'; import Services from './Services';
import Icon from "@mdi/react"; import Icon from "@mdi/react";
import {mdiCloseOutline} from "@mdi/js"; import {mdiCloseOutline} from "@mdi/js";
import * as identity from './api/identity'; import * as environment from './api/environment';
const Environments = (props) => { const Environments = (props) => {
const humanizeDuration = require("humanize-duration") const humanizeDuration = require("humanize-duration")
const disableEnvironment = (envId) => { const disableEnvironment = (envId) => {
console.log(envId) console.log(envId)
if(window.confirm('really disable environment "' + 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); console.log(resp);
}) })
} }

View File

@ -1,5 +1,5 @@
import {useState} from "react"; import {useState} from "react";
import * as identity from './api/identity'; import * as account from './api/account';
const Login = (props) => { const Login = (props) => {
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
@ -11,7 +11,7 @@ const Login = (props) => {
const handleSubmit = async e => { const handleSubmit = async e => {
e.preventDefault() e.preventDefault()
identity.login({body: {"email": email, "password": password}}) account.login({body: {"email": email, "password": password}})
.then(resp => { .then(resp => {
if (!resp.error) { if (!resp.error) {
let user = { let user = {

View File

@ -2,7 +2,7 @@ import Icon from "@mdi/react";
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import {mdiContentCopy} from "@mdi/js"; import {mdiContentCopy} from "@mdi/js";
import * as identity from "./api/identity"; import * as account from "./api/account";
const RegistrationForm = (props) => { const RegistrationForm = (props) => {
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
@ -20,7 +20,7 @@ const RegistrationForm = (props) => {
if(confirm !== password) { if(confirm !== password) {
setMessage(passwordMismatchMessage); setMessage(passwordMismatchMessage);
} else { } else {
identity.register({body: {"token": props.token, "password": password}}) account.register({body: {"token": props.token, "password": password}})
.then(resp => { .then(resp => {
if(!resp.error) { if(!resp.error) {
console.log("resp", resp) console.log("resp", resp)
@ -110,7 +110,7 @@ const Register = () => {
useEffect(() => { useEffect(() => {
let mounted = true let mounted = true
identity.verify({body: {token: token}}).then(resp => { account.verify({body: {token: token}}).then(resp => {
if(mounted) { if(mounted) {
if(resp.error) { if(resp.error) {
setActiveRequest(false); setActiveRequest(false);

View File

@ -6,9 +6,9 @@ import * as service from './api/service';
const Services = (props) => { const Services = (props) => {
const humanizeDuration = require("humanize-duration") const humanizeDuration = require("humanize-duration")
const unshareService = (envId, svcName) => { const unshareService = (envId, svcToken) => {
if(window.confirm('really disable service "' + svcName +'"?')) { if(window.confirm('really disable service "' + svcToken +'"?')) {
service.unshare({body: {zId: envId, svcName: svcName}}).then(resp => { service.unshare({body: {zId: envId, svcToken: svcToken}}).then(resp => {
console.log(resp) console.log(resp)
}) })
} }
@ -17,12 +17,12 @@ const Services = (props) => {
const columns = [ const columns = [
{ {
name: 'Frontend', name: 'Frontend',
selector: row => row.frontend, selector: row => row.frontendEndpoint,
sortable: true, sortable: true,
}, },
{ {
name: 'Backend', name: 'Backend',
selector: row => row.backend, selector: row => row.backendProxyEndpoint,
sortable: true, sortable: true,
}, },
{ {

View File

@ -5,15 +5,15 @@
* @typedef accessRequest * @typedef accessRequest
* @memberof module:types * @memberof module:types
* *
* @property {string} zId * @property {string} envZId
* @property {string} svcName * @property {string} svcToken
*/ */
/** /**
* @typedef accessResponse * @typedef accessResponse
* @memberof module:types * @memberof module:types
* *
* @property {string} frontendName * @property {string} frontendToken
*/ */
/** /**
@ -126,9 +126,9 @@
* @memberof module:types * @memberof module:types
* *
* @property {string} zId * @property {string} zId
* @property {string} name * @property {string} token
* @property {string} frontend * @property {string} frontendEndpoint
* @property {string} backend * @property {string} backendProxyEndpoint
* @property {module:types.serviceMetrics} metrics * @property {module:types.serviceMetrics} metrics
* @property {number} createdAt * @property {number} createdAt
* @property {number} updatedAt * @property {number} updatedAt
@ -166,17 +166,17 @@
* @typedef unaccessRequest * @typedef unaccessRequest
* @memberof module:types * @memberof module:types
* *
* @property {string} frontendName * @property {string} frontendToken
* @property {string} zId * @property {string} envZId
* @property {string} svcName * @property {string} svcToken
*/ */
/** /**
* @typedef unshareRequest * @typedef unshareRequest
* @memberof module:types * @memberof module:types
* *
* @property {string} zId * @property {string} envZId
* @property {string} svcName * @property {string} svcToken
*/ */
/** /**