Skip to content

feat(auth): validate fc_ api keys via tenant-store#37

Merged
jbiskur merged 2 commits into
mainfrom
feat/fc-api-key-tenant-store-validation
Jul 5, 2026
Merged

feat(auth): validate fc_ api keys via tenant-store#37
jbiskur merged 2 commits into
mainfrom
feat/fc-api-key-tenant-store-validation

Conversation

@jbiskur

@jbiskur jbiskur commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

authenticate() only parsed the legacy ApiKey <keyId>:<secret> header form and always validated against ${api_key_url}/validate-organization-api-key — so modern fc_<keyId>_<secret> api keys cannot authenticate through any service built on this library (single-token headers parse to apiKey: undefined, and the legacy validator doesn't know fc_ keys).

Change

  • Parse both header forms: ApiKey <id>:<secret-or-full-fc-key> and single-token ApiKey fc_<id>_<secret>.
  • fc_ keys → POST ${tenant_store_url}/api/v1/api-keys/validate with body { apiKey }. The parsed key is forwarded as-is, never reconstructed — re-wrapping is the double-wrap bug that broke service-tenant-api v2.14.0 in production.
  • Legacy non-fc_ keys stay on the api_key_url path byte-for-byte; fc_ keys also fall back to it if tenant_store_url is explicitly unset.
  • New auth.tenant_store_url option, defaulting to https://tenant-store.api.flowcore.io, so services get fc_ support on upgrade with no config change.

Mirrors the change just shipped in service-iam-service v1.34.0 (flowcore-io/service-iam-service#89). First consumer: service-tenant-store-api, to accept api-key principals on its api-key management routes.

Tests

test/authenticate.test.ts — fc_ single-token routing + exact body, legacy-form-carrying-fc_ no-double-wrap, apiKeyId fallback, valid:false → 401, legacy key stays on legacy path, fc_ + no tenant_store_url falls back to legacy.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MmTkzbSACo6PhBj9o1Sr8A

jbiskur and others added 2 commits July 5, 2026 19:32
The ApiKey branch only parsed the legacy "ApiKey <id>:<secret>" header
form and always validated against validate-organization-api-key, so
modern fc_<id>_<secret> keys could not authenticate through any service
built on this library.

- Parse both header forms (colon form and single-token fc_ form).
- fc_ keys -> POST ${tenant_store_url}/api/v1/api-keys/validate with
  body { apiKey } — forwarded as-is, never reconstructed (re-wrapping is
  the double-wrap bug that broke service-tenant-api v2.14.0).
- Legacy non-fc_ keys stay on api_key_url unchanged.
- New auth option tenant_store_url, defaulting to the public
  tenant-store endpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmTkzbSACo6PhBj9o1Sr8A
CI's deno lint (no-import-prefix / no-unversioned-import) fails on every
branch because src, test, and bin used inline jsr:/npm: imports. Map
them in deno.json and reference bare specifiers; update the lockfile so
--frozen-lockfile installs keep working.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmTkzbSACo6PhBj9o1Sr8A
@jbiskur jbiskur merged commit 512c823 into main Jul 5, 2026
1 check passed
@jbiskur jbiskur deleted the feat/fc-api-key-tenant-store-validation branch July 5, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant