anyproto / anyproto/anytype-api

Space-scoped API keys: bind a key to specific space(s)

Open
#69 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
113
Forks
20
Avg merge
16m
Merged PRs (30d)
1

Description

Have you read a contributing guide?
  • I have read CONTRIBUTING.md
  • I have searched the existing requests and didn't find any that were similar
  • I have considered creating a pull request instead and want to proceed
Clear and concise description of the problem

API keys from the local-link flow (/v1/auth/challenges/v1/auth/api_keys) are vault-wide: the token reaches every space via GET /v1/spaces, POST /v1/search, and any /v1/spaces/{space_id}/....

This breaks least-privilege for AI/MCP integrations. anytype-mcp exposes the full API to an LLM, so installing it grants the model the entire vault (cf. anytype-mcp#68). Many users want to expose just one space (e.g. a dedicated "AI" space) — currently impossible.

Suggested solution

Add a space dimension to key issuance, extending the scoped-token mechanism from anytype-heart#2021 (AccountAuthLocalApiScope):

  1. Accept an optional space_ids: string[] on challenge/key creation. Omitting it keeps current behavior (backward compatible).
  2. For a space-scoped key: out-of-scope /v1/spaces/{space_id}/...403; GET /v1/spaces lists only in-scope spaces; POST /v1/search is constrained to them.
  3. Expose the key's scope via key introspection.
Alternative

Capability scopes from #2021 (Limited/JsonAPI/Full) limit the API surface, not which spaces — they don't solve this.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the local-link flow from /v1/auth/challenges to /v1/auth/api_keys, then review the scoped-token mechanism referenced from anytype-heart#2021. Check how GET /v1/spaces, POST /v1/search, space-specific endpoints, and key introspection enforce existing scopes. Done means optional space_ids remain backward compatible while scoped keys restrict all listed operations and expose their scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, authorization, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.