Repository navigation
feat: add read/write/delete scopes to API tokens - #10349
harshdubey1234 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
da6e808 to
6700320
Compare
API tokens could do everything their owner can, including deleting work items and whole projects. Tokens now carry scopes (read, write, delete) that are checked on every /api/v1 request. Existing tokens keep all three, so current integrations are unaffected. Refs makeplane#10221
6700320 to
58a385f
Compare
Description
Part of #10221. This first PR adds token scopes; per-token rate limits will follow in a separate PR.
The problem
Teams connect bots and scripts to Plane with API tokens. Today, every token can do everything its owner can, including deleting work items and entire projects.
Example: you give a reporting bot a token so it can read work items for a weekly summary. If the token leaks, or the bot has a bug, that same token can delete your whole project, and there is no way to give the bot read-only access.
The solution
When you create an API token, you can now choose what it is allowed to do:
readwritedeleteA read-only token can still view everything. If it tries to create, change or delete anything, Plane refuses the request with a clear message, and nothing changes.
Existing tokens keep all three scopes, so current integrations work exactly as before.
sequenceDiagram participant Bot as Reporting bot (read-only token) participant API as Plane API Bot->>API: List work items API-->>Bot: 200 OK, work items returned Bot->>API: Delete project API-->>Bot: 403 "This API token does not have the 'delete' scope." Note over API: Project is untouchedAPI changes
POST /api/users/api-tokens/) accepts an optionalscopeslist, e.g.["read"]. If it's left out, the token gets all three scopes.scopes. Scopes are fixed when the token is created; to give a bot more access, create a new token./api/v1/): a request the token's scopes don't allow returns403with a message naming the missing scope.Data model changes
scopescolumn onapi_tokens. A migration gives every existing token all three scopes.Root-cause investigation
Before writing code, I used Operate to trace how Plane checks API tokens. It found that tokens carried no information about what they were allowed to do, so there was nothing to check against.
Full investigation: https://operatex.dev/open-source/github/makeplane/plane/issues/10221
Type of Change
Screenshots and Media (if applicable)
Loom walkthrough of the fix in action: link will be added here shortly.
Test Scenarios
Same requests, sent to a running Plane server before and after this change:
Automated tests cover each scope, token creation and validation, and existing tokens. The external API test suite passes (433 tests).
References