API tokens with write scopes so third parties can build frontends #209

Open
opened 2026-12-01 18:31:11 +01:00 by midas · 0 comments
Owner

Third parties should be able to build their own frontends and clients against PodRadar. Session cookies are the wrong vehicle for that: SameSite=Lax keeps them off cross-site requests, browsers block third-party cookies, and every origin would have to be registered in PODRADAR_CORS_ALLOWED_ORIGINS.

API tokens (Authorization: Bearer pdr_…) have no CSRF exposure, so they can be served to any origin. Today that chain is read-only and limited to a small whitelist of endpoints, built for podradar-mcp.

Proposal

  • Give tokens scopes (at least read and write), chosen when the token is created; existing tokens stay read-only.
  • Put the whole /api/** surface behind the token chain, with write endpoints requiring the write scope. Decide explicitly which endpoints stay session-only (account/password, token management, admin).
  • Open CORS for bearer-authenticated requests: any origin, Authorization allowed, no credentials. The cookie-based CORS allow-list stays as it is.
  • Document the API for client authors (enable/describe the OpenAPI output).

Open questions

  • Token issuance for a third-party web app: copy-paste from settings is enough to start; an OAuth-style flow could follow later.
  • Rate limiting per token.

Follows from the same-origin change in the PR for fix/csrf-same-origin.

Third parties should be able to build their own frontends and clients against PodRadar. Session cookies are the wrong vehicle for that: `SameSite=Lax` keeps them off cross-site requests, browsers block third-party cookies, and every origin would have to be registered in `PODRADAR_CORS_ALLOWED_ORIGINS`. API tokens (`Authorization: Bearer pdr_…`) have no CSRF exposure, so they can be served to any origin. Today that chain is read-only and limited to a small whitelist of endpoints, built for `podradar-mcp`. ## Proposal - Give tokens scopes (at least `read` and `write`), chosen when the token is created; existing tokens stay read-only. - Put the whole `/api/**` surface behind the token chain, with write endpoints requiring the `write` scope. Decide explicitly which endpoints stay session-only (account/password, token management, admin). - Open CORS for bearer-authenticated requests: any origin, `Authorization` allowed, no credentials. The cookie-based CORS allow-list stays as it is. - Document the API for client authors (enable/describe the OpenAPI output). ## Open questions - Token issuance for a third-party web app: copy-paste from settings is enough to start; an OAuth-style flow could follow later. - Rate limiting per token. Follows from the same-origin change in the PR for `fix/csrf-same-origin`.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/podradar#209
No description provided.