feat(auth): validate fc_ api keys via tenant-store#37
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
authenticate()only parsed the legacyApiKey <keyId>:<secret>header form and always validated against${api_key_url}/validate-organization-api-key— so modernfc_<keyId>_<secret>api keys cannot authenticate through any service built on this library (single-token headers parse toapiKey: undefined, and the legacy validator doesn't know fc_ keys).Change
ApiKey <id>:<secret-or-full-fc-key>and single-tokenApiKey fc_<id>_<secret>.POST ${tenant_store_url}/api/v1/api-keys/validatewith 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.api_key_urlpath byte-for-byte; fc_ keys also fall back to it iftenant_store_urlis explicitly unset.auth.tenant_store_urloption, defaulting tohttps://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