feat: support External IdP authentication and current Claude Code clients - #274
Open
robert-mcdermott wants to merge 3 commits into
Open
feat: support External IdP authentication and current Claude Code clients#274robert-mcdermott wants to merge 3 commits into
robert-mcdermott wants to merge 3 commits into
Conversation
Add first-class support for enterprise Kiro IDE sessions authenticated through external OIDC providers such as Microsoft Entra ID. Detect external_idp credentials, refresh tokens through the configured HTTPS token endpoint, persist rotated credentials, add the required TokenType header, and discover profile ARNs from Kiro IDE storage. Includes bounded retries, endpoint validation, JSON and SQLite support, documentation updates, and comprehensive tests. Tests: uv run pytest -q Result: 1717 passed
Accept system-role entries inside the Anthropic messages array and promote their content into Kiro's system prompt. Preserve user and assistant message ordering so the actual user request remains the active turn. Combine inline instructions with the standard top-level system prompt. Add coverage for streaming, non-streaming, token counting, multiple system messages, invalid roles, and system-only requests. Update the Anthropic API documentation.
|
Thanks for the PR! 馃帀 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
Author
|
I have read the CLA and I accept its terms |
|
@robert-mcdermott could you please give a try to this gateway: https://github.com/ankitcharolia/kiro-gateway It works quite well with All AI harness and actively being developed. The most important thing is that it is ACP compliant. Happy to have your Feedback. Thank you! |
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
This PR improves compatibility with current Kiro IDE enterprise sessions and Claude Code clients.
It adds:
systemmessagesMotivation
Current Kiro IDE versions may authenticate enterprise users through an external OIDC provider. These credentials contain fields such as:
authMethod: "external_idp"clientIdissuerUrltokenEndpointscopesThe gateway previously classified these credentials as Kiro Desktop authentication and sent the refresh token to:
That endpoint rejects External IdP refresh tokens with HTTP 401.
Additionally, current Claude Code versions can place
system-role messages inside themessagesarray. The gateway's Anthropic request model rejected these requests during Pydantic validation with HTTP 422.Changes
External IdP authentication
EXTERNAL_IDPauthentication typeauthMethod: "external_idp"orprovider: "ExternalIdp"tokenEndpointrecorded by KiroTokenType: EXTERNAL_IDPheader to Kiro runtime and MCP endpointsprofileArnfrom Kiro IDE extension storage when it is absent from the credential fileSecurity
External IdP endpoints are validated before use:
Claude Code compatibility
systemas an Anthropic message rolesystemfield/v1/messages/count_tokensdeveloperThis fixes errors such as:
Fallback model list
Add the following model identifiers to the fallback
/v1/modelsresponse:claude-opus-5claude-sonnet-5claude-opus-4.8gpt-5.6-solgpt-5.6-terragpt-5.6-lunaThese entries help clients that require model selection from
/v1/models. Model resolution remains pass-through, so Kiro remains the final authority on whether a model is available to the authenticated account.Documentation
.env.exampleTesting
Full test suite:
Coverage includes:
TokenTypeheadersManual verification
Verified with:
The previously failing Claude Code request now returns HTTP 200 and a valid Anthropic SSE response.