mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 16:13:47 +01:00
don't forward the error details
This commit is contained in:
parent
e61de01d9d
commit
3b9e6c5072
@ -3,7 +3,6 @@ package controller
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -33,7 +32,7 @@ func (self *createAccountHandler) Handle(params identity.CreateAccountParams) mi
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
@ -48,7 +47,7 @@ func (self *createAccountHandler) Handle(params identity.CreateAccountParams) mi
|
||||
logrus.Warnf("found previous account request for '%v', removing", params.Body.Email)
|
||||
if err := str.DeleteAccountRequest(oldAr.Id, tx); err != nil {
|
||||
logrus.Errorf("error deleteing previous account request for '%v': %v", params.Body.Email, err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
} else {
|
||||
logrus.Warnf("error finding previous account request for '%v': %v", params.Body.Email, err)
|
||||
@ -56,16 +55,16 @@ func (self *createAccountHandler) Handle(params identity.CreateAccountParams) mi
|
||||
|
||||
if _, err := str.CreateAccountRequest(ar, tx); err != nil {
|
||||
logrus.Errorf("error creating account request for '%v': %v", params.Body.Email, err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing account request for '%v': %v", params.Body.Email, err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
|
||||
if err := sendVerificationEmail(params.Body.Email, token, self.cfg); err != nil {
|
||||
logrus.Errorf("error sending verification email for '%v': %v", params.Body.Email, err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
|
||||
logrus.Infof("account request for '%v' has registration token '%v'", params.Body.Email, ar.Token)
|
||||
|
@ -27,7 +27,7 @@ func (self *disableHandler) Handle(params identity.DisableParams, principal *res
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return identity.NewDisableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewDisableInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
envId, err := self.checkZitiIdentity(params.Body.Identity, principal, tx)
|
||||
@ -37,20 +37,20 @@ func (self *disableHandler) Handle(params identity.DisableParams, principal *res
|
||||
}
|
||||
if err := self.removeEnvironment(envId, tx); err != nil {
|
||||
logrus.Errorf("error removing environment: %v", err)
|
||||
return identity.NewDisableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewDisableInternalServerError()
|
||||
}
|
||||
edge, err := edgeClient(self.cfg.Ziti)
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting edge client: %v", err)
|
||||
return identity.NewDisableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewDisableInternalServerError()
|
||||
}
|
||||
if err := self.deleteEdgeRouterPolicy(params.Body.Identity, edge); err != nil {
|
||||
logrus.Errorf("error deleting edge router policy: %v", err)
|
||||
return identity.NewDisableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewDisableInternalServerError()
|
||||
}
|
||||
if err := self.deleteIdentity(params.Body.Identity, edge); err != nil {
|
||||
logrus.Errorf("error deleting identity: %v", err)
|
||||
return identity.NewDisableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewDisableInternalServerError()
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing: %v", err)
|
||||
|
@ -34,27 +34,27 @@ func (self *enableHandler) Handle(params identity.EnableParams, principal *rest_
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return identity.NewEnableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewEnableInternalServerError()
|
||||
}
|
||||
|
||||
client, err := edgeClient(self.cfg.Ziti)
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting edge client: %v", err)
|
||||
return identity.NewEnableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewEnableInternalServerError()
|
||||
}
|
||||
ident, err := self.createIdentity(principal.Email, client)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return identity.NewEnableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewEnableInternalServerError()
|
||||
}
|
||||
cfg, err := self.enrollIdentity(ident.Payload.Data.ID, client)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return identity.NewEnableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewEnableInternalServerError()
|
||||
}
|
||||
if err := self.createEdgeRouterPolicy(ident.Payload.Data.ID, client); err != nil {
|
||||
logrus.Error(err)
|
||||
return identity.NewEnableInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewEnableInternalServerError()
|
||||
}
|
||||
envId, err := str.CreateEnvironment(int(principal.ID), &store.Environment{
|
||||
Description: params.Body.Description,
|
||||
@ -65,11 +65,11 @@ func (self *enableHandler) Handle(params identity.EnableParams, principal *rest_
|
||||
if err != nil {
|
||||
logrus.Errorf("error storing created identity: %v", err)
|
||||
_ = tx.Rollback()
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing: %v", err)
|
||||
return identity.NewCreateAccountInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewCreateAccountInternalServerError()
|
||||
}
|
||||
logrus.Infof("recorded identity '%v' with id '%v' for '%v'", ident.Payload.Data.ID, envId, principal.Email)
|
||||
|
||||
|
@ -11,20 +11,20 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return metadata.NewOverviewInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return metadata.NewOverviewInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx)
|
||||
if err != nil {
|
||||
logrus.Errorf("error finding environments for '%v': %v", principal.Email, err)
|
||||
return metadata.NewOverviewInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return metadata.NewOverviewInternalServerError()
|
||||
}
|
||||
var out rest_model_zrok.EnvironmentServicesList
|
||||
for _, env := range envs {
|
||||
svcs, err := str.FindServicesForEnvironment(env.Id, tx)
|
||||
if err != nil {
|
||||
logrus.Errorf("error finding services for environment '%v': %v", env.ZitiIdentityId, err)
|
||||
return metadata.NewOverviewInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return metadata.NewOverviewInternalServerError()
|
||||
}
|
||||
es := &rest_model_zrok.EnvironmentServices{
|
||||
Environment: &rest_model_zrok.Environment{
|
||||
|
@ -31,20 +31,20 @@ func (self *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *res
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
edge, err := edgeClient(self.cfg.Ziti)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
svcName := params.Body.Service
|
||||
svcId, err := self.findServiceId(svcName, edge)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
var senv *store.Environment
|
||||
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
|
||||
@ -57,11 +57,11 @@ func (self *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *res
|
||||
if senv == nil {
|
||||
err := errors.Errorf("environment with id '%v' not found for '%v", params.Body.ZitiIdentityID, principal.Email)
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelNotFound().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelNotFound()
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("error finding environments for account '%v': %v", principal.Email, err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
|
||||
var ssvc *store.Service
|
||||
@ -75,32 +75,32 @@ func (self *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *res
|
||||
if ssvc == nil {
|
||||
err := errors.Errorf("service with id '%v' not found for '%v'", svcId, principal.Email)
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelNotFound().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelNotFound()
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("error finding services for account '%v': %v", principal.Email, err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
|
||||
if err := self.deleteServiceEdgeRouterPolicy(svcName, edge); err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
if err := self.deleteServicePolicyDial(svcName, edge); err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
if err := self.deleteServicePolicyBind(svcName, edge); err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
if err := self.deleteConfig(svcName, edge); err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewTunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewTunnelInternalServerError()
|
||||
}
|
||||
if err := self.deleteService(svcId, edge); err != nil {
|
||||
logrus.Error(err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
|
||||
logrus.Infof("deallocated service '%v'", svcName)
|
||||
@ -108,11 +108,11 @@ func (self *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *res
|
||||
ssvc.Active = false
|
||||
if err := str.UpdateService(ssvc, tx); err != nil {
|
||||
logrus.Errorf("error deactivating service '%v': %v", svcId, err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error committing: %v", err)
|
||||
return tunnel.NewUntunnelInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return tunnel.NewUntunnelInternalServerError()
|
||||
}
|
||||
|
||||
return tunnel.NewUntunnelOK()
|
||||
|
@ -21,7 +21,7 @@ func (self *verifyHandler) Handle(params identity.VerifyParams) middleware.Respo
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return identity.NewVerifyInternalServerError().WithPayload(rest_model_zrok.ErrorMessage(err.Error()))
|
||||
return identity.NewVerifyInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user