feat(oauth): migrate GitLab token from JSON file to operator_oauth_tokens #824
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!824
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/gitlab-oauth-to-db"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes one of three slices of #823.
Summary
oauth-gitlab.tsnow reads viagetOperatorOAuth("gitlab")and writes viaupsertOperatorOAuth({ forge_type: "gitlab", … })— same pattern as the Forgejo / GitHub flows.~/.local/state/claude-hooks/gitlab-oauth-token.jsonretired. Idempotent migration012ports any existing JSON file into the DB on first boot, thenunlinks the file.The callback now also fetches the operator profile from
/api/v4/usersoaccount_login/account_idland with real values instead of sentinels (mirrors forgejo / github).Changes
apps/server/src/http/handlers/oauth-gitlab.ts— DB-backed; droppedgitlabOAuthTokenPath,mkdir,readFile,writeFile,writeGitLabToken. Added profile fetch.apps/server/src/http/handlers/oauth-gitlab.test.ts(new) — 11 tests covering token read / refresh / no-row, init redirect, callback happy path + profile failure fallback + missing state + exchange failure.apps/server/src/infrastructure/database/migrations/012-migrate-gitlab-oauth-to-db.ts(new) — file-existence + row-existence guards; AEAD-encrypts viaencryptToken.apps/server/src/infrastructure/database/migrations/012-migrate-gitlab-oauth-to-db.test.ts(new) — 5 tests: happy migrate, idempotent re-run, file-present-row-present (file unlinked, row preserved), no-file no-op, malformed JSON (file kept, no throw).apps/server/src/infrastructure/database/db.ts— wiredrunMigrateGitlabOauthToDbMigrationintoensureSchema()afterrunCollapseBuiltinRowsMigration.Notes
account_login: "unknown"/base_url: "https://gitlab.com"when the legacy file lacked them; the next callback overwrites with real values from/api/v4/user.setActiveForge('gitlab')to the GitLab callback — those weren't in the original handler and this PR is scoped to persistence shape. Bringing GitLab to operator-login parity is a separate cut-over.Test plan
012against an instance that hasgitlab-oauth-token.jsonand confirm row + file removal🤖 Generated with Claude Code
38025dc7bb32004da955All
operator_oauth_tokensACs from #823 met.oauth-gitlab.ts: JSON file I/O cleanly replaced withgetOperatorOAuth/upsertOperatorOAuth/updateOAuthTokenAfterRefresh;gitlabOAuthTokenPathfully removed (no dangling references).encryptToken, falls back to sentinels for missingaccount_login/base_url.