mirror of
https://github.com/openziti/zrok.git
synced 2025-06-24 11:41:25 +02:00
allow access to private share service from unrelated environment (#109)
This commit is contained in:
parent
44a95598a3
commit
39302cd4d5
@ -47,20 +47,14 @@ func (h *accessHandler) Handle(params service.AccessParams, principal *rest_mode
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logrus.Errorf("error finding environments for account '%v'", principal.Email)
|
logrus.Errorf("error finding environments for account '%v'", principal.Email)
|
||||||
return service.NewAccessInternalServerError()
|
return service.NewAccessNotFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
ssvcs, err := str.FindServicesForEnvironment(envId, tx)
|
svcName := params.Body.SvcName
|
||||||
|
ssvc, err := str.FindServiceWithName(svcName, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("error finding services for environment")
|
logrus.Errorf("error finding service")
|
||||||
return service.NewAccessInternalServerError()
|
return service.NewAccessNotFound()
|
||||||
}
|
|
||||||
var ssvc *store.Service
|
|
||||||
for _, v := range ssvcs {
|
|
||||||
if v.Name == params.Body.SvcName {
|
|
||||||
ssvc = v
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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'", params.Body.SvcName, principal.Email)
|
||||||
|
@ -53,6 +53,14 @@ func (self *Store) GetAllServices(tx *sqlx.Tx) ([]*Service, error) {
|
|||||||
return svcs, nil
|
return svcs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Store) FindServiceWithName(svcName string, tx *sqlx.Tx) (*Service, error) {
|
||||||
|
svc := &Service{}
|
||||||
|
if err := tx.QueryRowx("select * from services where name = $1", svcName).StructScan(svc); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "error selecting service by name")
|
||||||
|
}
|
||||||
|
return svc, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Store) FindServicesForEnvironment(envId int, tx *sqlx.Tx) ([]*Service, error) {
|
func (self *Store) FindServicesForEnvironment(envId int, tx *sqlx.Tx) ([]*Service, error) {
|
||||||
rows, err := tx.Queryx("select services.* from services where environment_id = $1", envId)
|
rows, err := tx.Queryx("select services.* from services where environment_id = $1", envId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user