Repository navigation
fix(keycardai-oauth): impersonate() accepts a client assertion (ECO-455) - #366
Merged
Merged
Conversation
Both impersonate() methods take keyword-only client_assertion and client_assertion_type and pass them into the TokenExchangeRequest the way exchange_token() does, so an application whose credential is a workload identity can authenticate the substitute-user exchange in the request body. Omitting them leaves the wire request unchanged. Co-Authored-By: Larry Osakwe <larry@keycard.ai>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Larry-Osakwe
approved these changes
Oct 20, 2026
Larry-Osakwe
left a comment
Contributor
There was a problem hiding this comment.
Reviewed against ECO-455: the assertion reaches the form body, Basic auth is unchanged for client secrets, tests pin both.
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
AsyncClient.impersonate()andClient.impersonate()had no way to carry a client assertion, althoughexchange_token()andclient_credentials_grant()in the same client acceptclient_assertion/client_assertion_type. An application whose credential is a workload identity (no client secret) therefore could not authenticate the substitute-user exchange. Parity half of ECO-455; the TypeScript fix is typescript-sdk #265.Both methods take two new keyword-only parameters and pass them into the
TokenExchangeRequestexactly asexchange_token()does:The request serializer drops
Nonefields (model_dump(exclude_none=True)), so omitting them produces the same bytes as before. No validation was added:exchange_token()does not requireclient_assertion_typewhen an assertion is given, andimpersonate()follows it rather than inventing a stricter rule in one method. Docstring examples on both methods show the workload identity call.Tests
tests/keycardai/oauth/test_impersonate_client_assertion.py, sync and async:subject_token_typestays the substitute-user URN, noAuthorizationheader is sent (both fail against main withTypeError: unexpected keyword argument 'client_assertion')exchange_token()produces for the same substitute-userTokenExchangeRequest, and contains noclient_assertionVerification
No manual version or CHANGELOG edits;
fix(keycardai-oauth)cuts the release.Link to Devin session: https://app.devin.ai/sessions/bbc062cf32b548ef9c4b8b444d2ec67f
Open in Devin Desktop: https://app.devin.ai/desktop/session/bbc062cf32b548ef9c4b8b444d2ec67f?variant=devin
Requested by: @Larry-Osakwe