Skip to content

fix(credentials): scope GitLab personal tokens to organizations - #7603

Merged
TheodoreSpeaks merged 1 commit into
fix/org-account-provisioningfrom
fix/org-personal-tokens
Sep 8, 2026
Merged

fix(credentials): scope GitLab personal tokens to organizations#7603
TheodoreSpeaks merged 1 commit into
fix/org-account-provisioningfrom
fix/org-personal-tokens

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Store personal GitLab tokens under the organization and connecting user, so the same connection works across accessible workspaces. Tokens remain private; workflow sharing permissions do not change.
  • Update connection, lookup, rotation, and disconnect paths to use organization ownership while retaining the workspace as execution context.
  • Add a resumable, dry-run-first data migration that preserves credential IDs and re-encrypts ownership bindings. Run it after deployment; duplicate identities and conflicting enrollments fail rather than being overwritten. No new schema migration is needed.

Stacked on #7598.

Type of Change

  • Bug fix

Testing

  • 801 credential unit tests and 9 PostgreSQL integration tests passed, covering migration, cross-workspace use, identity isolation, revocation, reconnect, rotation, and deletion of the original workspace.
  • App/auth type checks, repository lint, API boundary checks, migration safety, and shipping audits passed.
  • No staging or production data migration has been run.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 8, 2026 7:40pm UTC

Request Review

@TheodoreSpeaks
TheodoreSpeaks merged commit 69a73bc into fix/org-account-provisioning Sep 8, 2026
5 checks passed
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

The PR should not merge until the migration safely handles or rejects existing delivery_failed organization enrollments.

Findings

  1. P1 Failed enrollment remains unusable

Summary

  • Extends credential contracts, queries, presentation, authorization, and client cache keys for organization-owned personal tokens.
  • Rebinds encrypted token envelopes to organization scope and preserves creator-only access across workspaces.
  • Adds a dry-run-first, resumable migration and integration coverage for migration, rotation, revocation, deletion, and cross-workspace use.
  • The migration currently mishandles an existing delivery_failed organization enrollment, producing a successfully migrated but unusable credential.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Legacy workspace GitLab token] --> B[Validate workspace, owner, enrollment, and ciphertext]
  B --> C[Find organization Connected accounts group]
  C --> D{Existing organization enrollment?}
  D -- No --> E[Create in-progress enrollment]
  D -- Yes --> F[Validate and reuse enrollment]
  E --> G[Re-encrypt token with organization binding]
  F --> G
  G --> H[Set organization owner and clear workspace owner]
  H --> I[Use from accessible workspaces in the organization]
Loading

Comment on lines +177 to +181
if (
target &&
(target.revokedAt ||
target.status === 'revoked' ||
(target.userId && target.userId !== owner.id))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed enrollment remains unusable

When an existing organization enrollment is in delivery_failed state and already has the owner's user ID, this check accepts it and the later update leaves its status unchanged. The migration then binds the credential to that enrollment and reports success, but normal token resolution only accepts invited, in_progress, or completed enrollments. The migrated token is therefore unusable. Reject delivery_failed targets or transition them to in_progress, as the live connection path does.

Knowledge Base Used:

@waleedlatif1
waleedlatif1 deleted the fix/org-personal-tokens branch September 8, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant