Let fine-grained tokens read the Source Code GraphQL types
What does this MR do and why?
Without an authorize_granular_token directive, a fine-grained token gets no data from 11 Source Code types and cannot run BranchRuleSquashOptionCreate. Each now declares one and leaves authorization_todo.txt:
- The three commit signature types take
read_commit_signatureandCommitReferencesread_commit_ref, as the commitsignatureandrefsendpoints do.PathLocktakesread_code, whichread_path_locksfollows. ForkDetailstakesread_codeon the upstream, and its resolver on the fork, as the field checks the user: the change !267275 (merged) left for later.BranchRuleSquashOptionCreatetakescreate_squash_optionon the branch rule's project, as the update mutation does. This addscreate_squash_optionto the existingcreate_branch_rule, asupdate_branch_ruleanddelete_branch_rulehold the other two.- The types returned only below those take their parent's permission with
parent_authorizes:.SquashOptionskips without one until the branch rule type has a directive.
It also declares the parent permission of Blame, RepositoryCodeownerValidation and AccessLevelDeployKey, as offered in !269587 (comment 4204222716) (details below). Key stays on the list: as a TodoableInterface type, a parent permission on it would differ from the other types Todo.target returns.
This is the Source Code domain in one MR, as @alexbuijs agreed in !267273 (comment 4195231927). Most of its 447 lines are specs, one for every parent of each type; the code is 29 lines.
Each type, its parents and its directive
| Types | Returned by | Directive |
|---|---|---|
GpgSignature, SshSignature, X509Signature |
Commit.signature |
read_commit_signature, project |
X509Certificate, X509Issuer |
X509Signature.x509Certificate, X509Certificate.x509Issuer |
parent_authorizes: :read_commit_signature |
CommitReferences |
Project.commitReferences |
read_commit_ref, project |
CommitParentNames |
the four tipping and containing fields of CommitReferences |
parent_authorizes: :read_commit_ref |
PathLock |
Project.pathLocks |
read_code, project |
PathLockPermissions |
PathLock.userPermissions |
parent_authorizes: :read_code |
ForkDetails |
Project.forkDetails, ProjectSyncFork |
read_code, the upstream; the resolver on the fork |
SquashOption |
the squash option mutations, BranchRule.squashOption |
skip_reason: :parent_authorizes |
BranchRuleSquashOptionCreate (mutation) |
create_squash_option, the branch rule's project |
The three types that already skipped with parent_authorizes:
Blametakesread_repository_blob, whatRepositoryBlobchecks. REST blame asksread_repository_file_blame; both are in Repository: Read, so I followed the parent, asTreeEntrydoes.RepositoryCodeownerValidationtakesread_code, whatRepositorychecks.AccessLevelDeployKeytakesread_deploy_key, the only permission the directive ofProject.availableDeployKeysaccepts. No field checks it at runtime yet, so no token changes.read_deploy_keyis not a project or group policy ability, soPushAccessLevel.deployKeywill need its own directive once its type has one.
References
Closes #639817
Related to #593878
I found this while working on gitlab-mcp-server.
Screenshots or screen recordings
No UI change.
How to set up and validate locally
-
In a private project with a GPG-signed commit and a path lock, run as a Maintainer with a token that reads Project, Code, Repository and Commit:
query { project(fullPath: "<project>") { repository { tree(ref: "<signed commit>") { lastCommit { signature { commitSha } } } } pathLocks { nodes { path } } } } -
On master the path locks are empty and
signatureisnull; on this branch they return data.
Checks I ran (Ruby 3.3.11)
I ran the steps above as examples of the changed request specs.
- With master's types, resolver, model and todo list, the changed specs give 202 examples, 28 failures. With master's
create_branch_ruleas well, the squash option create spec does not load, as no assignable permission holdscreate_squash_option. - On this branch, the changed specs and those of blame, the CODEOWNERS validation and the deploy keys: 228 examples, 0 failures.
gitlab:permissions:validate, RuboCop, Keela, the commit linter and Danger's linters pass; bothcompile_docstasks leave the committed docs unchanged. Left to the pipeline: Ruby 3.4.10 and the FOSS run.
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.