Add read-only Policy Store page to projects
What does this MR do and why?
This adds the plumbing for a new page under a project's Secure section, where a project will be able to see the security policies it inherits from its organization and group. Projects don't author policies themselves, so the page is read-only.
This MR is the backend half only. Nothing links to the page yet and it renders an empty container, so there is no user-visible change: the list, the sidebar entry and the data that fills them ship in the follow-up, !265278.
Details
- New route
resources :policy_store, only: [:index]inee/config/routes/project.rb, matching the group route. Index only: policies are authored at the organization or group, so there is deliberately nonew,showoredit. - New
Projects::Security::PolicyStoreController, authorizing throughSecurityPoliciesPermissionsthe same wayProjects::Security::PoliciesControllerdoes — authenticate, licensed feature, experiment active, thenread_govern_policy. - New HAML view providing the container element and its data attributes. It omits
new_policy_pathandlist_pathbecause the project surface has neither an authoring page nor a detail page. - Regenerated
config/routing/gitlab_routes.jsonandee/app/assets/javascripts/lib/utils/path_helpers/project.jsfrom their rake tasks. - A request spec covers the index for a maintainer, a guest, a project whose group has not opted into the experiment, and the unrouted
new/show/editpaths.
Why this is needed
Organization and group levels already have a Policy Store page. Projects need a read-only view of the policies that govern them, which is https://gitlab.com/gitlab-org/gitlab/-/issues/632454. This MR lands the route, controller and view so the follow-up can be purely the list and its query, rather than one change that is half routing and half frontend.
The split is deliberate: the sidebar entry is held back with the frontend, so no one can reach a page that shows nothing.
References
- https://gitlab.com/gitlab-org/gitlab/-/issues/632454
- Follow-up that makes the page do something: !265278
Screenshots or screen recordings
| Before | After |
|---|---|
| N/A | N/A |
N/A on both sides: this MR adds no user-reachable UI. There is no sidebar entry, nothing else links to the route, and a user who typed the URL would get an empty container with no heading, list or empty state. The first visible state of this page is in !265278, which carries the recording.
How to set up and validate locally
- Enable the
policy_store_experiment_enabledinstance setting. - Opt a root group in via its namespace setting (
NamespaceSetting#policy_store_experiment_enabled). - Open
<project>/-/security/policy_storefor a project in that group and confirm it returns 200 with an empty#js-policy-storecontainer. - Confirm
<project>/-/security/policy_store/new,/1and/1/editreturn 404. - Confirm a Guest on the same project gets a 404, and so does a project whose group has not opted in.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.