Skip to content

Advanced user search: Add namespace filtering

What does this MR do and why?

  1. Performs simple filtering when a group or project is selected.
  2. Enables group and project level advanced user searches behind a feature flag.

Filter requirements

Group filtering

For a group x with namespaces y and z, a user must match either:

  • A prefix on the full namespace i.e. z-y-x-
  • Any exact term of ancestors i.e. z-y- or z-
Project filtering

For a project A in group x with namespaces y and z, a user must match either:

  • The exact term of the project namespace ancestry i.e. z-y-x-pA-
  • Any exact term of the project's ancestors i.e. z-y-x-, z-y- or z-

Implementation

Change UserClassProxy when a project or group is selected to:

  • Get the namespace's ancestry
  • Break it up into ancestor parts
  • For projects: a terms query on namespace_ancestry_ids with the project's full ancestry and ancestor parts.
  • For groups:
    • a prefix query on namespace_ancestry_ids with the group's full ancestry.
    • a terms query on namespace_ancestry_ids with ancestor parts.

Result

Groups

Users who are members of the following are valid:

  1. The selected group
  2. Descendants of the selected group
  3. Projects belonging to descendants of the selected group
  4. Any of the selected groups' ancestors
Projects

Users who are members of the following are valid:

  1. The selected project
  2. The selected project's group
  3. Any of the selected project's group's ancestors

* NOT the project's group's descendants

Screenshots or screen recordings

Group filtering:

Project filtering:

How to set up and validate locally

  1. Make sure elasticsearch is running
  2. Enable advanced user search: Feature.enable(:advanced_user_search)
  3. Navigate to the web app and do a search without selecting a group. This should show all matching users
  4. Select a group. Verify that the users returned are members of the group, its ancestors or descendants, or descendant's projects
  5. Select a project. Verify that the users returned are members of the project, its group, or the group's ancestors

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #387503 (closed)

Edited by Madelein van Niekerk

Merge request reports

Loading