- Add ApiKey Prisma model (SHA-256 hash, prefix, lastUsedAt) with migration - Implement ApiKeyService (create, list, delete, verify) - Extend requireAuth middleware to accept sk_-prefixed API keys alongside JWTs - Add GET/POST /api-keys routes for creating and revoking keys - Add stateless Streamable HTTP MCP server at POST/GET /mcp exposing all 20 time-tracking tools (clients, projects, time entries, timer, statistics, client targets and corrections) - Frontend: ApiKey types, apiKeys API module, useApiKeys hook - Frontend: ApiKeysPage with key table, one-time raw-key reveal modal, and inline revoke confirmation - Wire /api-keys route and add API Keys link to Management dropdown in Navbar
25 lines
778 B
SQL
25 lines
778 B
SQL
-- AlterTable
|
|
ALTER TABLE "client_targets" ALTER COLUMN "working_days" DROP DEFAULT;
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "api_keys" (
|
|
"id" TEXT NOT NULL,
|
|
"name" VARCHAR(255) NOT NULL,
|
|
"key_hash" VARCHAR(64) NOT NULL,
|
|
"prefix" VARCHAR(16) NOT NULL,
|
|
"last_used_at" TIMESTAMP(3),
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"user_id" VARCHAR(255) NOT NULL,
|
|
|
|
CONSTRAINT "api_keys_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "api_keys_key_hash_key" ON "api_keys"("key_hash");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "api_keys_user_id_idx" ON "api_keys"("user_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|