fix(auth): support STS session token in sso-setup / publish discovery step - #139
Merged
innsd merged 1 commit intoJul 14, 2026
Merged
Conversation
When agentkit auth admin sso-setup / publish is run with temporary credentials (VOLCENGINE_ACCESS_KEY / VOLCENGINE_SECRET_KEY / VOLCENGINE_SESSION_TOKEN), every OpenAPI-based provisioning step succeeds, but publish_discovery() constructs the TOS client with only AK/SK and drops the session token. A temporary AK without its session token is invalid, so TOS rejects the request with 403 InvalidAccessKeyId. Fix by threading the session token through: - publish_discovery() accepts a session_token parameter with the same VOLCENGINE_SESSION_TOKEN env fallback used for AK/SK, and passes it to tos.TosClientV2 via security_token. - sso_setup() forwards session_token=api.token so the publish step uses the same credentials as the earlier provisioning steps. Backward compatible: with long-lived AK/SK the token is None and behavior is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
innsd
approved these changes
Jul 14, 2026
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
Running
agentkit auth admin sso-setup(oragentkit auth admin publish) with temporary STS credentials (VOLCENGINE_ACCESS_KEY/VOLCENGINE_SECRET_KEY/VOLCENGINE_SESSION_TOKEN) fails at the final "publish discovery doc to TOS" step:All earlier provisioning steps (UserPool, CLI client, OIDC provider, STS role, ...) succeed because
OpenApiClient(agentkit/auth/_openapi.py) already readsVOLCENGINE_SESSION_TOKENand includes it in the SigV4 signature. Butpublish_discovery()inagentkit/auth/admin.pybuilds the TOS client with only AK/SK:A temporary access key is invalid without its session token, so TOS rejects the request.
Fix
Three small changes to
agentkit/auth/admin.py:publish_discovery()gains asession_tokenparameter with an env fallback (VOLCENGINE_SESSION_TOKEN), mirroring the existing AK/SK handling.security_token:sso_setup()forwardssession_token=api.token, so the publish step uses the same credentials as the provisioning steps.The env fallback also fixes
agentkit auth admin publish, which callspublish_discoverywithout explicit credential arguments. Fully backward compatible: with long-lived AK/SK the token isNoneand behavior is unchanged.Verification
With temporary credentials configured, a read-only
head_bucketcall against the affected bucket (agentkit-cli-<account_id>) using the same AK/SK:TosServerError403, matching the original failure;After the fix, re-running
sso-setupcompletes; the command is idempotent and reuses previously created resources, only finishing the failed publish step.Related observation (not addressed here)
create_bucketerrors are treated as "bucket already exists" when the message containsExist/exist. The auth error message "...does not exist in our records" matches that keyword, so thecreate_bucketfailure was silently swallowed and only surfaced atput_object. Worth hardening separately by matching error codes (BucketAlreadyExists/BucketAlreadyOwnedByYou) instead of message keywords.🤖 Generated with Claude Code