Repository navigation
feat: gate self-service API key creation on an active billing plan (gap #9) - #81
Merged
Merged
Conversation
#9) POST /me/api-keys now calls omnibioai-billing's existing GET /organizations/{id}/subscription endpoint before issuing a new key, via a short-lived synthetic JWT minted with this service's own create_access_token -- no new shared secret, reusing the platform-wide signing key both services already trust. Infra failures (network error, timeout, 5xx, malformed JSON) fail open; a genuine "no subscription at all" (404) fails closed. See billing_client.py for the full rationale. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
POST /me/api-keysnow checks, before issuing a new key, that the caller's organization has an active (or trialing) subscription — via a newbilling_client.organization_has_active_plan(org_id).GET /organizations/{id}/subscriptionendpoint, authenticated with a short-lived synthetic JWT minted by this service's owncreate_access_token. No new shared secret: it reuses the platform-wide JWT signing key both services already trust, the same way any other validly-signed platform JWT with a matchingorg_idclaim would be accepted.404(no subscription at all) fails closed. Seeapp/services/billing_client.py's module docstring/comments.Test plan
pytest tests/test_billing_client.py tests/test_me_api_keys.py -q— 27 passedtest_mfa_recovery_code_atomicity.py::test_concurrent_requests_different_challenge_tokens_same_code_exactly_one_success, a timing-sensitive concurrency test unrelated to this change)🤖 Generated with Claude Code