Declare SaaS and self-managed assignable_when conditions
What does this MR do and why?
This MR is one of seven that split !253276 (merged) into pieces that each need only Authorization approval plus at most one other CODEOWNERS section. This one needs Authorization only.
A consumer earns a condition tag only when it rejects every request from a caller who does not meet the condition, for every parameter. Partial checks, feature flags, and license checks do not count. The saas and self_managed conditions cover Gitlab.com? and Gitlab::Saas.feature_available? guards and their inverse. The admin condition covers authenticated_as_admin! checks, and several consumers here carry both an admin tag and a saas or self_managed tag. Nothing changes at request time. The only effect is that the token creation UI stops offering a permission at boundaries where the current user does not meet the condition.
This MR tags 18 consumers (42 tags) with saas, self_managed, and admin conditions: GraphQL mutations for member role create, delete, and update, Duo model selection allowlist updates, organization creation, subscription activation, and billable promotion requests, plus GraphQL types for model selection allowlists and secrets manager instance enrollment, and REST endpoints for member roles, the Manage API groups endpoint, Google Cloud integration, security scans, namespaces, subscriptions, and organizations. 21 YAML files gain assignable_when, mostly under system_access (5, personal access tokens and ssh keys), subscription_and_licensing (6), groups (5, member roles and namespace), and duo (2, model selection allowlist), plus one file each under application_security, organizations, and secrets_management. Most of the 42 tags are saas (22) or admin (10). Six pairs need both admin and self_managed, three need both admin and saas, and one is self_managed alone.
Two RSpec examples change to match. spec/features/user_settings/granular_personal_access_tokens/token_creation_spec.rb no longer expects Member Role among the Groups resources, and spec/features/user_settings/granular_personal_access_tokens/token_duplication_spec.rb's source token now uses SSH Certificate read and create instead of member role permissions, because member role permissions at the group boundary become GitLab.com-only.
system_access/ssh_key/delete.yml also gains a saas condition at the group boundary here. The admin-authz MR adds a separate admin condition at the instance boundary to the same file. Whichever of the two merges second will need to rebase and merge both entries.
Instance GET /member_roles and GET /admin_member_roles stay untagged, because the shared helper switches to a group-level check whenever an id query parameter is present.
References
- Original MR being split: !253276 (merged)
- Parent MR that added GraphQL assignable_when support: !253246 (merged)
- MR that introduced assignable_when for REST endpoints: !246776 (merged)
- Sibling MRs from the same split:
- !253276 (merged) (Declare admin assignable_when conditions on granular token consumers)
- !255014 (merged) (Declare assignable_when conditions on Geo granular token consumers)
- !255015 (merged) (Declare assignable_when conditions on system hook consumers)
- !255016 (merged) (Declare assignable_when conditions on the admin token API)
- !255017 (merged) (Declare assignable_when conditions on the experiments API)
- !255022 (merged) (Declare assignable_when conditions on CI granular token consumers)
Screenshots or screen recordings
No UI changes in this MR.
How to set up and validate locally
-
Run
bundle exec rake gitlab:permissions:validate. It passes. -
Remove the
assignable_when:block fromconfig/authz/permission_groups/assignable_permissions/groups/member_role/create.ymland run the task again. It fails and lists the GraphQL and REST member role creation consumers, withConsumer conditions: [saas]for the group boundary andConsumer conditions: [admin, self_managed]for the instance boundary. Restore the block. -
Enable the
granular_personal_access_tokensfeature flag, then query the GraphQLaccessTokenPermissionsfield (or open the fine-grained token creation page) forcreate_member_role. The saas boundary only appears in theboundariesreturned on GitLab.com, not on a self-managed instance.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.