enhance(rtc): add graph-scoped personal access tokens - #13019
Draft
tiensonqin wants to merge 4 commits into
Draft
Conversation
tiensonqin
marked this pull request as draft
August 13, 2026 05:25
Contributor
There was a problem hiding this comment.
Pull request overview
Adds graph-scoped Personal Access Tokens (PATs) to Logseq’s DB Sync semantic REST API, including secure storage/verification in the Cloudflare Worker, management endpoints, and Settings UI + translations for RTC rollout users.
Changes:
- Introduces D1-backed PAT persistence plus Worker endpoints to create/list/revoke PATs, and semantic API auth that accepts
logseq_pat_bearer tokens with graph + scope restrictions. - Adds Settings UI for managing PATs (create, copy-once display, list, revoke) gated to RTC group users.
- Documents the design and security constraints in ADR 0023 and adds tests/migrations for the new behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/resources/dicts/en.edn | Adds English i18n strings for PAT Settings UI and actions. |
| src/resources/dicts/zh-cn.edn | Adds Simplified Chinese i18n strings for PAT Settings UI and actions. |
| src/main/frontend/handler/db_based/sync.cljs | Adds frontend API wrappers for PAT list/create/revoke calls. |
| src/main/frontend/components/settings.cljs | Implements PAT management UI in Settings and adds Settings navigation entry. |
| docs/adr/0023-db-sync-personal-access-tokens.md | Documents the accepted architecture/constraints for graph-scoped PATs. |
| deps/db-sync/worker/migrations/0007_add_personal_access_tokens.sql | Adds D1 migration creating the personal_access_tokens table + indexes. |
| deps/db-sync/test/logseq/db_sync/worker_dispatch_test.cljs | Adds tests covering PAT management auth, hashing, semantic permissions, and route exclusions. |
| deps/db-sync/src/logseq/db_sync/worker/handler/personal_access_token.cljs | Implements PAT management endpoints and RTC-group eligibility checks. |
| deps/db-sync/src/logseq/db_sync/worker/dispatch.cljs | Routes PAT management endpoints; updates semantic dispatch to use PAT-aware auth + rate limit keys. |
| deps/db-sync/src/logseq/db_sync/worker/auth.cljs | Adds PAT detection, SHA-256 hashing, and semantic auth claims lookup by token hash. |
| deps/db-sync/src/logseq/db_sync/index.cljs | Adds PAT table bootstrap SQL and D1 helpers for CRUD + graph-delete cleanup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1363
to
+1365
| {:class "self-start" | ||
| :disabled (or pending? (empty? graph-items)) | ||
| :on-click create!} |
Comment on lines
+76
to
+77
| (p/let [raw-body (common/read-json request) | ||
| body (when raw-body (js->clj raw-body :keywordize-keys true))] |
Comment on lines
+1357
to
+1360
| {:type "date" | ||
| :value expiration | ||
| :min (subs (.toISOString (js/Date.)) 0 10) | ||
| :on-change #(set-expiration! (util/evalue %))})]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
logseq_pat_bearer tokens on the semantic REST API with read, write, or both permissionsSecurity
Complete token values are returned only at creation time. The server stores SHA-256 hashes, validates expiration and current graph access on use, and rejects personal access tokens on raw sync, assets, graph management, E2EE, WebSocket, and admin routes.
Validation
bb dev:lint-and-testbb dev:db-sync-test(205 tests, 4176 assertions)clojure -M:test release appbb lang:validate-translationsbb lang:lint-hardcoded --git-changedbb lang:format-dictsgit diff --check