Files
pad/internal/store/migrations/011_api_tokens.sql
T
xarmian cf83a60fc2 feat: Add API tokens system for programmatic access
Add a complete API tokens system enabling CI/CD integrations, custom
scripts, and third-party tools to authenticate with the Pad API.

- Migration 011: api_tokens table with hash-based token storage
- Model: APIToken, APITokenCreate, APITokenWithSecret types
- Store: CRUD operations with crypto/rand generation and SHA-256 hashing
- Middleware: Bearer token auth that sets workspace context
- Handlers: POST/GET/DELETE /workspaces/{ws}/tokens endpoints
- CORS: Allow Authorization header for token-based requests
2026-03-28 14:13:50 +00:00

13 lines
379 B
SQL

CREATE TABLE IF NOT EXISTS api_tokens (
id TEXT PRIMARY KEY,
workspace_id TEXT NOT NULL,
name TEXT NOT NULL,
token_hash TEXT NOT NULL,
prefix TEXT NOT NULL,
scopes TEXT NOT NULL DEFAULT '["*"]',
expires_at TEXT,
last_used_at TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (workspace_id) REFERENCES workspaces(id)
);