Repository navigation
Commit adffab4
authored
feat: allow coding agents to authenticate with claimable temporary accounts (#23225)
## Summary
<!-- What changed and why. Link to issue if applicable. -->
<!-- Remember: we squash-merge, so this description becomes the commit
message. -->
Allow coding agents to authenticate with claimable temporary accounts
The CLI now detects common coding-agent environments and keeps normal
human CLI authentication behavior unchanged. When running as an agent,
it prefers existing usable credentials, but if home credentials are
inaccessible it creates an ephemeral Pulumi account through the agent
signup endpoint.
Automatically created agent credentials and claim metadata are stored in
a shared temporary Pulumi directory (`/tmp/.pulumi` on non-Windows, `<OS
temp dir>/.pulumi` on Windows) so sandboxed agent sessions on the same
host and OS user can reuse them. The CLI prints claim instructions while
claim metadata is present, asks agents to surface the claim URL, warns
that claiming locks the org during the claim process, and tells agents
to finish work before the user claims the account.
If agent authentication fails after the account has been claimed or
otherwise becomes unavailable, the CLI asks the user to run `pulumi
login`. It also explains that the stacks the agent was working with may
have moved to the user’s Pulumi account and that the agent’s access to
those stacks may have changed. The CLI validates stored claim tokens
before surfacing stale claim URLs and records unavailable claims to
avoid repeatedly checking them.
Expired claim state is cleaned up when the claim URL and access token
have expired.
## Test plan
<!-- How did you test this change? -->
- [x] Added appropriate unit tests - For all changes
- [ ] Added a test in `pkg/engine/lifecycletest` - For all
engine/protocol changes
- [ ] Added a conformance test in `pkg/testing/pulumi-test-language` -
For language protocol changes
- [ ] Added a golden test in `pkg/backend/display` - For changes to the
output renderers
## Validation
<!-- Commands you ran. Do not include output, but make sure that you've
run these and checked the results. -->
- [x] `make lint` — clean
- [ ] `make test_fast` — all pass
- [x] `make tidy_fix` — clean
- [x] `make format` — clean
- [x] Relevant SDK tests pass (if SDK changes)
- [x] `make check_proto` — clean (if proto changes)
## Changelog
<!-- Does this PR need a changelog entry? If so, did you run `make
changelog`? -->
- [x] Changelog entry added. If you do not believe this PR requires a
changelog, ask a maintainer to apply the `impact/no-changelog-required`
label.
## Risk
<!-- What could go wrong? What's the blast radius? Does this affect
public API? -->
The main risk is unintended account selection in agent mode.
If the CLI misclassifies a human shell as an agent, it could enter the
agent-auth fallback path. The current detection is env-var based, so
this mainly happens if someone has agent-like env vars set outside an
actual agent session.
Credential-source mistakes are the second risk. We explicitly avoided
copying `PULUMI_ACCESS_TOKEN` or readable home credentials into `/tmp`,
but bugs in this routing could leak user credentials into a shared temp
dir. The current implementation only writes auto-created agent account
credentials to the shared temporary Pulumi directory.
Another risk is orphaned infrastructure state. If signup succeeds and
claim metadata is missing, expired, or never shown, an agent can create
stacks in an account the user may not claim. The CLI now validates
stored claim tokens before surfacing claim URLs after authentication
failures, but claim instructions still depend on local claim metadata
being written and preserved.
There is also a service compatibility risk: the CLI now depends on
unauthenticated Pulumi Cloud agent signup and claim-validation
endpoints. If those endpoint shapes change, agent auto-auth or
stale-claim detection can break.
### Blast Radius
Mostly CLI authentication behavior for detected coding-agent
environments.
Non-agent human CLI behavior should be unchanged. Existing
`PULUMI_ACCESS_TOKEN`, `PULUMI_HOME`, and `PULUMI_CREDENTIALS_PATH`
behavior remains authoritative and should fail rather than silently
falling back when those explicit paths are inaccessible.
For agents, the blast radius includes login/current-backend selection,
stack listing, stack creation, service secrets access, private Pulumi
Cloud template retrieval, and any command that needs a cloud backend. It
can also affect shared host behavior because the shared temporary Pulumi
directory is intentionally reused across sandboxed agents on the same
machine, scoped by OS user permissions.
### Public API
Yes, indirectly.
The CLI calls unauthenticated Pulumi Cloud agent endpoints:
- `GET /api/agents/signup`
- `POST /api/agents/signup`
- `GET /api/agents/signup/validate/{claimToken}`
Signup is challenge-based. The first request receives `challengeID` and
`challengeData`; the second request sends `challengeID`,
`challengeResult`, and agent metadata.
The CLI relies on the final signup response contract:
{
"accessToken": "...",
"accessTokenValidUntil": "...",
"claimToken": "...",
"claimTokenValidUntil": "..."
}
The CLI derives the claim URL from `claimToken`.
If expiration timestamps are missing or malformed, the CLI cannot
reliably decide when to stop showing claim warnings or when to clean up
shared agent state.
<!--
NOTE: maintainer time is a limited resource. Pull requests that do not
follow this template can create
avoidable work and may be closed without review. Repeatedly ignoring
these guidelines may result in
temporary or permanent restrictions to your ability to contribute to
this project.
-->1 parent fe4520c commit adffab4
40 files changed
Lines changed: 4655 additions & 183 deletions
File tree
- changelog/pending
- pkg
- backend/httpstate
- client
- cmd/pulumi
- agentauth
- auth
- backend
- cmd
- metadata
- packagecmd
- templates
- secrets/service
- sdk
- go
- common
- util/agentdetect
- workspace
- pulumi-language-go
- pcl
- tests/integration
- construct_component_provider_propagation/go
- construct_component_resource_options/go
- construct_nested_component/go
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments