mirror of
https://github.com/openziti/zrok.git
synced 2025-02-22 05:01:01 +01: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 {
|
||||
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 {
|
||||
logrus.Errorf("error finding services for environment")
|
||||
return service.NewAccessInternalServerError()
|
||||
}
|
||||
var ssvc *store.Service
|
||||
for _, v := range ssvcs {
|
||||
if v.Name == params.Body.SvcName {
|
||||
ssvc = v
|
||||
break
|
||||
}
|
||||
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)
|
||||
|
@ -53,6 +53,14 @@ func (self *Store) GetAllServices(tx *sqlx.Tx) ([]*Service, error) {
|
||||
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) {
|
||||
rows, err := tx.Queryx("select services.* from services where environment_id = $1", envId)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user