Conversation
- Partner GraphQL client (src/utils/graphql.ts) and JIT tenant token cache (src/utils/jit.ts): apiTokensGenerateJit per account, cached 14 min, keyed by partner-key hash + account id, in-flight de-dup, evicted on auth failure, JWT never logged - New `partner` domain: knowbe4_partner_accounts_list, knowbe4_partner_account_get - Optional `account_id` on every tenant tool; when set the call is served over the tenant GraphQL API via JIT token (src/graphql/<domain>.ts), otherwise the REST path is unchanged - Env mode: KNOWBE4_PARTNER_API_KEY (+ KNOWBE4_GRAPHQL_URL); gateway mode: X-KnowBe4-Partner-API-Key, 401 only when neither key is present; knowbe4_status reports both credentials - Fix: knowbe4_store_* and knowbe4_policies_* were unreachable in non-lazy mode because dispatch matched six hard-coded prefixes; route via the tool category map instead Claude-Session: https://claude.ai/code/session_017fK8GjLU5PbuRc4UR62PFc
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- card.builder normalizes both REST snake_case and GraphQL camelCase users (status from `archived`, name from displayName, trend from riskScoreHistories) - partner-mode knowbe4_users_get attaches the MCP Apps _card, fetching the risk history over GraphQL best-effort - partner-mode knowbe4_users_list offers the same filter prompt as REST when called without filters Claude-Session: https://claude.ai/code/session_017fK8GjLU5PbuRc4UR62PFc
…eless-assignment Claude-Session: https://claude.ai/code/session_017fK8GjLU5PbuRc4UR62PFc
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
MSPs currently need one KnowBe4 Reporting API key per customer tenant. This adds partner mode: one partner Product API key drives every managed tenant through KnowBe4's partner GraphQL API and per-tenant Just-In-Time (JIT) tokens.
KNOWBE4_PARTNER_API_KEY(env) /X-KnowBe4-Partner-API-Key(gateway).KNOWBE4_API_KEYbecomes optional; gateway mode accepts either key or both.partnerdomain:knowbe4_partner_accounts_list(search/status/pagination, returns each tenant's risk score, phish-prone %, % trained, seats, subscription end) andknowbe4_partner_account_get.account_id. When set, the call runs over the tenant GraphQL API with a JIT token fromapiTokensGenerateJit(accountId), cached 14 min (documented lifetime 15 min), keyed bysha256(partnerKey)[:16]:accountIdso partners sharing a gateway process never share tokens. Concurrent calls share one mint; a 401 evicts the cached token. JWTs are never logged.account_idthe REST path is byte-for-byte unchanged.account_idhas no REST fallback: unconfigured partner mode returns an error instead of answering from the wrong tenant.src/graphql/<domain>.ts, same tool names / args / validation messages. Selections kept small for KnowBe4's 150-line complexity cap; page sizes clamped to 25..1000.Also fixes a latent dispatch bug:
knowbe4_store_*andknowbe4_policies_*were unreachable in non-lazy mode (prefix routing only knew six prefixes). Routing now uses the category map.Design notes:
docs/superpowers/specs/2026-09-09-partner-mode-design.md.Verification
https://training.knowbe4.com/graphql?scope=public_kmsatand?scope=partner_public_kmsaton 2026-09-09.fetch/tenantQuery; an end-to-end stdio smoke test against a local mock GraphQL endpoint confirmed tool listing, JIT minting/caching, and the no-partner-key error path.Test plan
npm testnpm run lintnpm run buildknowbe4_partner_accounts_list, thenknowbe4_users_listwithaccount_idhttps://claude.ai/code/session_017fK8GjLU5PbuRc4UR62PFc