Applies to: vkit 2.0.0 with VaultKit 0.13.0-alpha or later (see Upgrading to vkit 2.0.0)
A setup session lets a coding agent set VaultKit up for you without ever holding your
own login. It works like gh auth login: the agent asks for a session, you approve it
in the console, and the agent gets a token that can only do setup, for 30 minutes.
Set Up VaultKit with a Coding Agent uses one. This page explains what you’re approving.
vkit login --setup. vkit shows a code, such as
BJCQ-6006, and a link to the console’s approval page.vkit logout, or when
you revoke it.Everything the token does is recorded in Activity as “agent setup on behalf of” you.
See Setup sessions in the CLI reference for the commands and
their --format json output.
The link opens /setup/approve in the console. Only admins can approve; a member is
told an admin has to. If the link has no code, or the wrong one, the page asks you to
type the code from your terminal.
The page shows:
User-Agent, such as “Requested 2 minutes ago from 203.0.113.7,
vkit/2.0.0 (macOS arm64; ruby 3.3.8)”. The User-Agent is whatever the client sent,
so treat it as a hint, not proof.It can do what vkit needs for setup, and nothing else:
| It can | vkit commands |
|---|---|
| Read who it is | vkit whoami |
| List, read and add datasources | vkit datasource list, get, add |
| Scan a datasource, in either mode | vkit scan |
| Read the registry | vkit registry export, vkit registry diff |
| Upload and activate policy bundles | vkit policy deploy |
| Read approval groups and setup status | vkit policy deploy’s warnings, vkit doctor |
| End itself | vkit logout |
vkit policy bundle, vkit policy validate and vkit init run locally and need no
endpoint.
It can’t query data, approve or deny requests, fetch or revoke grants, create,
list or revoke agent tokens, manage users or settings, read Activity, or revoke or
roll back policy bundles. Each of those returns 403 setup_scope_forbidden. So once
setup is done, the agent token for the agent itself is created by you, in the console
or with your own vkit login (see Creating agent tokens).
The token also stops working if the admin who approved it is no longer an active admin
of the organization (setup_approver_not_admin).
A setup token sets an organization up; by default it can’t change one that already is.
Uploading or activating a bundle, adding a datasource and vkit scan --mode apply work
only while the organization has no active policy bundle, or when the active bundle was
deployed by this same setup session. Otherwise they return 403 setup_scope_forbidden:
API 403: This organization is already set up: policy bundle 4b7657fa… is active and was not
deployed by this setup session. An admin must deploy changes to an organization that is
already set up; a setup token can only set up a new one, or redo its own setup.
Steps that change nothing always work, so rerunning setup with a new session is safe:
already_existed: true);already_deployed: true);scan --mode apply that finds nothing new (unchanged: true).To let a new session change an existing setup, for example to finish one whose first session expired, tick Allow this session to replace existing policies and datasources when you approve it. The box appears only when there’s something to replace, it’s unticked by default, and your choice is recorded with the approval.
vkit logout ends it on the control plane, not just locally:
🔒 Setup session ended on the control plane.setup_session_revoked); what it already set up stays.Commands return setup_session_expired. Run vkit login --setup again and approve
the new session. Every setup step is safe to rerun. If the first session already
deployed a bundle or added a datasource, the new one can rerun those steps unchanged;
to change them, tick “Allow this session to replace existing policies and datasources”
when you approve it.
The principal is the setup session, shown in Activity as “agent setup on behalf of ada@example.com”:
setup_session.requested (when an admin first opens the link, with the requester’s
IP and User-Agent), setup_session.approved (with what the organization already had,
and whether replacing was allowed), setup_session.denied,
setup_session.token_issued, setup_session.revoked and setup_session.expired;setup_session.action for every request made with the token, and
setup_session.action_refused for each one refused.The events of the things it does, such as datasource.created and
policy_bundle.created, keep you as the principal and add the setup session to their
details.
Starting a session is limited to 10 per IP address per minute, and polling to 60;
over the limit is 429 rate_limited.