Add deploy-token-{id} identifier
What does this MR do and why?
Adds deploy-token-{id} identifier support to Gitlab::Identifier and GitAccessActor so the system can deserialize deploy token identifiers.
Currently, Gitlab::GlId.gl_id generates user-{id} for all actors including deploy tokens, causing ID collisions with real users. The fix for git audit event HTTP requests consists of three parts:
- Fix the deserializer so
Identifier#identifyandGitAccessActor.from_identifiercan resolvedeploy-token-{id}back to aDeployTokenobject.
-
Fix
GlIdgeneration forDeployToken(!222599 (merged))
- Fix the serializer to produce
deploy-token-{id}.
-
Migrate the Audit system from using
usernametoidentifier(#570236 (closed))
- Update Workhorse to send
GL_IDasidentifierparam (instead of onlyGL_USERNAMEasusername) to theinternal/shellhorse/git_audit_eventendpoint, soGitAccessActor.from_paramscan resolve deploy tokens via theparams[:identifier]branch.
These changes must be deployed in this order.
Impact analysis
Investigated all consumers of GL_ID across the GitLab ecosystem to verify the format change is safe:
-
Workhorse: Treats
GL_IDas an opaque string. The two places that pass it to Gitaly (receive-pack.go,ssh.go) are push-only paths. Deploy tokens have nowrite_repositoryscope (doc), so they cannot push. The audit event path (git-http.go) usesGL_USERNAME, notGL_ID. No impact. -
Gitaly:
parseAndSetGLIDininternal/gitlab/http_client.goparsesGL_IDand only recognizesuser-,key-, andusername-prefixes.deploy-token-{id}would fail validation. However, this is only called frompreReceiveHook(push only).PostReceiveat line 269 passesGL_IDas an opaqueidentifierstring without parsing. No impact. -
gitlab-shell: Deploy tokens do not support SSH authentication (doc).
deploy-token-{id}will never enter gitlab-shell. No impact. -
Rails:
Identifier#identifyis the only code that parsesGL_IDand would break. This MR fixes it. Other consumers (GitPostReceive#identify,Geo::PushUser,Geo::GitPushHttp) are either push-only paths or don't parse the format. Fixed by this MR.
References
- Task: #570235 (closed)
- Parent issue: #562516
- Epic: gitlab-org#20506
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.
Edited by Emma Park