Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • O open-build-service
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • obs
  • open-build-service
  • Merge requests
  • !43

api: models: Consider group roles to compute forbidden projects

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Ariel D'Alessandro requested to merge wip/adalessandro/hidden-project-group-roles into collabora/staging Sep 23, 2022
  • Overview 4
  • Commits 1
  • Pipelines 4
  • Changes 2

Task https://phabricator.apertis.org/T9073

Issue summary

There's an issue in the frontend, not considering the group relationships for the different projects.

For example: adding a group as maintainer role is expected to allow its members to see/modify the hidden project.

<project name="testproject">
  <person userid="Admin" role="maintainer"/>
  <group groupid="testgroup" role="maintainer"/>
  <access>
    <disable/>
  </access>
</project>

This is not working as expected. Login in as a member of testgroup is still not being able to access project testproject nor see it.

Debugging

The project model is querying the database by name in:

https://gitlab.collabora.com/obs/open-build-service/-/blob/collabora/staging/src/api/app/models/project.rb#L441

  def self.find_by_name(name, opts = {})
    dbp = find_by(name: name)

but the project model contains a default_scope defined at:

https://gitlab.collabora.com/obs/open-build-service/-/blob/collabora/staging/src/api/app/models/project.rb#L90

  default_scope { where('projects.id not in (?)', Relationship.forbidden_project_ids) }

which will filter out projects in advance if are contained in Relationship.forbidden_project_ids.

This is computed in:

https://gitlab.collabora.com/obs/open-build-service/-/blob/collabora/staging/src/api/app/models/relationship.rb#L71

  # calculate and cache forbidden_project_ids for users
  def self.forbidden_project_ids

The query is considering those projects with access=disable, but it's only considering the user relationships (i.e. <person> tags in the project meta config).

https://gitlab.collabora.com/obs/open-build-service/-/blob/collabora/staging/src/api/app/models/relationship.rb#L79

      Relationship.find_by_sql("SELECT ur.project_id, ur.user_id from flags f,
                relationships ur where f.flag = 'access' and f.status = 'disable' and ur.project_id = f.project_id").each do |r|

So, indeed, the group relationships (i.e. <group> tags in the project meta config) are missing.

Edited Sep 26, 2022 by Ariel D'Alessandro
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: wip/adalessandro/hidden-project-group-roles