Skip to content

enhance(rtc): add graph-scoped personal access tokens - #13019

Draft
tiensonqin wants to merge 4 commits into
masterfrom
feature/db-sync-personal-access-tokens
Draft

enhance(rtc): add graph-scoped personal access tokens#13019
tiensonqin wants to merge 4 commits into
masterfrom
feature/db-sync-personal-access-tokens

Conversation

@tiensonqin

Copy link
Copy Markdown
Contributor

Summary

  • document graph-scoped personal access tokens in ADR 0023
  • add D1 storage and JWT-protected create, list, and revoke endpoints for RTC rollout users
  • support logseq_pat_ bearer tokens on the semantic REST API with read, write, or both permissions
  • restrict every token to one eligible non-E2EE graph and preserve existing raw sync authentication
  • add Personal Access Token management to Logseq Settings with English and Simplified Chinese translations

Security

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-test
  • bb dev:db-sync-test (205 tests, 4176 assertions)
  • clojure -M:test release app
  • bb lang:validate-translations
  • bb lang:lint-hardcoded --git-changed
  • bb lang:format-dicts
  • git diff --check

@github-actions github-actions Bot added the :type/feature New feature label Aug 12, 2026
@tiensonqin
tiensonqin marked this pull request as ready for review August 13, 2026 05:23
Copilot AI lite review requested due to automatic review settings August 13, 2026 05:23
@tiensonqin
tiensonqin marked this pull request as draft August 13, 2026 05:25

Copilot AI left a comment

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.

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 %))})]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:type/feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants