Backend: Filter catalog resources based on user permissions
Problem
When a user marks the components repository as being a catalog resource we expect the project to be available in the catalog. However, we need to ensure that projects are exposed in the catalog only to users who have the right permissions.
For example:
- You are a user of
gitlab-org/gitlab. -
gitlab-org/security/dastandgitlab-org/security/sastare 2 components repositories where everyone ingitlab-orggroup can access. -
gitlab-org/internalis a sub-group accessible only to a limited number ofgitlab-orgmembers. This sub-group contains a components repositoryreport-x.
flowchart TD
gitlab-org --> gitlab([gitlab])
gitlab-org --> internal --> report-x[[report]]
gitlab-org --> security --> dast[[dast]]
security --> sast[[sast]]
Expectations
- If you don't have access to
gitlab-org/internalyou should not see the components repositorygitlab-org/internal/report-xlisted in the catalog. - As you have access to
gitlab-org/securitysub-group you will see the components repositoriesgitlab-org/security/dastandgitlab-org/security/sast.
Proposal
We already have Ci::Catalog::Listing class that represents the baseline scope of resources in a given root namespace. We can leverage ProjectsFinder or at least the filter by permissions and pass the Ci::Catalog::Listing#resources through this permissions filter, to ensure we don't expose accidentally resources to users that don't have permissions.
Edited by Fabio Pitino