Repository navigation
feat(agent-vault): create sessions on behalf of users #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
scott-ray-wilson
wants to merge
1
commit into
main
Choose a base branch
from
AGE2-288
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 On a server without #8773, callers asking for a session on behalf of a user silently get a 7d session for the machine identity, using the identity's values and full bundle access. create() sends
onBehalfOfand returns the server's session without checking it, so a dropped key raises nothing. The docstring calls this accepted, but self-hosted servers can't be upgraded in step with the SDK. Fix: when either on_behalf_of argument is set, call get(id) and check thatonBehalfOfis present. If it isn't, revoke the session and raise. Also send ttl="1h" when ttl is None, so a session that slips through still expires as documented.Why this was flagged
Trigger: a caller on the new SDK runs create(access_bundle=..., on_behalf_of_user_email=...) against an Infisical server older than #8773, for example a self-hosted install not yet upgraded. The PR says zod there strips the unknown
onBehalfOfkey. agent_vault.py:289-302 builds the body with ttl dropped (None, removed by post_once at infisical_requests.py:220), posts it and returns result.data.session. Nothing checks that the server honouredonBehalfOf. The server then creates an ordinary machine-identity session with its 7d default. The caller gets back a CreatedAgentVaultSession token with no error. So an agent meant to run with user-scoped, 1h access runs with identity-scoped access for a week. On the base branch create() had no on-behalf parameter, so nobody could believe they had a delegated session. The docstring warning at agent_vault.py:266-268 and the PR's 'release only after #8773 is deployed' plan do not protect self-hosted users, whose servers lag SDK releases.Verification: With ttl defaulting to None, post_once removes the ttl key (infisical_requests.py:218-220). The older server then applies its 7d default. The code returns
result.data.sessionwithout checking anything (agent_vault.py:289-302). The return type, CreatedAgentVaultSession (api_types.py:566-573), has no onBehalfOf field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for now. Agent Vault doesn't have adoption yet, so there's no one on an older server for this to affect, and this PR merges only after Infisical/infisical#8773 is deployed to Cloud. The
createdocstring covers older self-hosted servers in the meantime.