mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
more naming refactoring 'name' -> 'token' (#119)
This commit is contained in:
parent
483babe813
commit
f9143c3a5b
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package private_frontend
|
||||
|
||||
type Config struct {
|
||||
IdentityName string
|
||||
SvcName string
|
||||
SvcToken string
|
||||
Address string
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"`
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -87,7 +87,7 @@ function buildGraph(overview) {
|
||||
item.services.forEach((item) => {
|
||||
out.nodes.push({
|
||||
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},
|
||||
style: { width: 'fit-content', backgroundColor: '#9367ef', color: 'white' },
|
||||
type: 'output',
|
||||
|
@ -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);
|
||||
})
|
||||
}
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
},
|
||||
{
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user