docs

Setup Sessions

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.


How it works

  1. The agent asks for one with vkit login --setup. vkit shows a code, such as BJCQ-6006, and a link to the console’s approval page.
  2. You approve it in the console, signed in as an admin of your organization. The code must be approved within 10 minutes.
  3. The agent gets a setup token. It lasts 30 minutes, acts for you, and can only reach the setup endpoints listed below. vkit saves it like a normal login.
  4. The agent runs setup: adds the datasource, scans it, deploys policies.
  5. The session ends when it expires, when the agent runs 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 approval page

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:


What a setup token can and can’t do

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).


An organization that’s already set up

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:

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.


Ending a session

When it expires part way

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.


In the audit log

The principal is the setup session, shown in Activity as “agent setup on behalf of ada@example.com”:

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.