@@ -142,6 +142,7 @@ const (
142142type GraphWalkUsecase struct {
143143 enforceSecurity security.EnforceSecurity
144144 executorFactory executor_factory.ExecutorFactory
145+ featureAccessReader OrganizationUsecaseFeatureAccessReader
145146 dataModelRepository repositories.DataModelRepository
146147 graphRepository repositories.GraphRepository
147148 graphRelationRepository repositories.GraphRelationRepository
@@ -159,15 +160,25 @@ type GraphWalkUsecase struct {
159160// matches reached. Everything newly found feeds the next degree.
160161func (uc GraphWalkUsecase ) WalkGraph (
161162 ctx context.Context ,
162- organizationId uuid.UUID ,
163163 startType , startId string ,
164164 opts models.GraphWalkOptions ,
165165) (models.GraphResult , error ) {
166- if err := uc .enforceSecurity .ReadOrganization (organizationId ); err != nil {
166+ orgId := uc .enforceSecurity .OrgId ()
167+
168+ fa , err := uc .featureAccessReader .GetOrganizationFeatureAccess (ctx , orgId , nil )
169+ if err != nil {
170+ return models.GraphResult {}, err
171+ }
172+
173+ if ! fa .GraphExploration .IsAllowed () {
174+ return models.GraphResult {}, errors .Wrap (models .ForbiddenError ,
175+ "organization not allowed to use the graph exploration feature" )
176+ }
177+ if err := uc .enforceSecurity .ReadOrganization (orgId ); err != nil {
167178 return models.GraphResult {}, err
168179 }
169180
170- dataModel , err := uc .dataModelRepository .GetDataModel (ctx , uc .executorFactory .NewExecutor (), organizationId , false , true )
181+ dataModel , err := uc .dataModelRepository .GetDataModel (ctx , uc .executorFactory .NewExecutor (), orgId , false , true )
171182 if err != nil {
172183 return models.GraphResult {}, err
173184 }
@@ -184,12 +195,12 @@ func (uc GraphWalkUsecase) WalkGraph(
184195
185196 // An organization declares its own shared-attribute relations against its own data model. An
186197 // organization that has declared none still gets a walk: it just follows links only.
187- relations , err := uc .graphRelationRepository .ListGraphRelations (ctx , uc .executorFactory .NewExecutor (), organizationId )
198+ relations , err := uc .graphRelationRepository .ListGraphRelations (ctx , uc .executorFactory .NewExecutor (), orgId )
188199 if err != nil {
189200 return models.GraphResult {}, err
190201 }
191202
192- exec , err := uc .executorFactory .NewClientDbExecutor (ctx , organizationId )
203+ exec , err := uc .executorFactory .NewClientDbExecutor (ctx , orgId )
193204 if err != nil {
194205 return models.GraphResult {}, err
195206 }
@@ -220,7 +231,7 @@ func (uc GraphWalkUsecase) WalkGraph(
220231 return models.GraphResult {}, err
221232 }
222233
223- if err := uc .enrichGraph (ctx , organizationId , exec , dataModel , graph ); err != nil {
234+ if err := uc .enrichGraph (ctx , orgId , exec , dataModel , graph ); err != nil {
224235 return models.GraphResult {}, err
225236 }
226237
0 commit comments