vkit)Command-line interface for VaultKit β secure, policy-driven data access control plane
The VaultKit CLI (vkit) is the primary interface for interacting with the VaultKit control plane. It enables users to request governed data access, track approvals, manage datasources, and deploy policy bundlesβall while maintaining complete audit trails.
The VaultKit CLI provides command-line access to VaultKit for:
| Capability | Description |
|---|---|
| Authentication | Login, session management, identity verification |
| Data Requests | Submit AQL queries with automatic policy evaluation |
| Approval Workflows | Approve or deny access requests requiring authorization |
| Grant Management | Fetch data using approved, time-limited grants |
| Datasource Admin | Register and manage database connections (admin only) |
| Schema Discovery | Scan datasources and detect schema drift |
| Policy Deployment | Build, validate, and deploy policy bundles |
| Audit Queries | Search and export audit logs |
VaultKit uses a request β policy β grant β fetch workflow:
ββββββββββββ ββββββββββββ βββββββββ βββββββββ βββββββββββββ
β Request β -> β Policy β -> β Grant β -> β Fetch β -> β Audit Log β
β (AQL) β β Eval β β (JWT) β β Data β β (Record) β
ββββββββββββ ββββββββββββ βββββββββ βββββββββ βββββββββββββ
Key Principles:
gem install vaultkitcli
vkit --version
# => VaultKit CLI v0.1.0
vkit --help
export VKIT_API_URL=http://localhost:3000
For production:
export VKIT_API_URL=https://vaultkit.company.com
vkit login --endpoint http://localhost:3000 --email analyst@company.com
Youβll receive a prompt for your password or be redirected to SSO.
vkit request --aql '{
"source_table": "customers",
"columns": ["id", "email", "total_spend"],
"limit": 10
}'
If granted immediately:
vkit fetch --grant gr_abc123xyz
If approval required:
# Check status
vkit requests list --state pending
# After approval
vkit fetch --grant gr_abc123xyz
vkit loginAuthenticate with the VaultKit control plane.
vkit login --endpoint http://localhost:3000 --email analyst@acme.com
Options:
--endpoint β VaultKit API endpoint (can also use VKIT_API_URL)--email β Email address for authenticationSSO Integration:
If your organization uses SSO, youβll be redirected to your identity provider:
vkit login --endpoint https://vaultkit.company.com --email you@company.com
# Output:
# Opening browser for SSO authentication...
# β Authentication successful
# Session expires: 2024-01-15 18:00:00 UTC
vkit whoamiDisplay the currently authenticated user and session information.
vkit whoami
Output:
π€ analyst@acme.com (role: analyst, org: acme)
JSON Format:
vkit whoami --format json
Output:
{
"email": "analyst@acme.com",
"role": "analyst",
"org": "acme"
}
vkit logoutClear stored credentials and end session.
vkit logout
# 1. Submit request
vkit request --aql '{
"source_table": "public_reports",
"columns": ["report_id", "title", "published_date"],
"limit": 10
}'
# Output:
# β Request granted immediately
# Grant ID: gr_abc123xyz
# TTL: 4 hours
# Use: vkit fetch --grant gr_abc123xyz
# 2. Fetch data
vkit fetch --grant gr_abc123xyz --format table
# 1. Submit request
vkit request --aql '{
"source_table": "financial_transactions",
"columns": ["transaction_id", "amount", "customer_id"],
"filters": [{"field": "amount", "operator": "gt", "value": 10000}]
}'
# Output:
# β³ Approval required
# Request ID: req_20240115_xyz789
# Approver: finance_manager
# Reason: Financial data requires manager approval
# Status: PENDING
# 2. Check status
vkit requests list --state pending
# 3. After approval, fetch data
vkit fetch --grant gr_approved_abc123
vkit request --aql '{
"source_table": "payment_cards",
"columns": ["card_number", "cvv"],
"limit": 10
}'
# Output:
# β Request denied
# Reason: Direct payment card data access forbidden
# Policy: pci_dss_restrictions
# Alternative: Use tokenized_card_id field instead
# Audit ID: audit_20240115_denied_123
vkit loginAuthenticate with VaultKit.
vkit login --endpoint <URL> --email <EMAIL>
Options:
--endpoint, -e β VaultKit API endpoint (default: $VKIT_API_URL)--email β User email address--password β Password (prompted if not provided)Examples:
# Interactive login
vkit login --endpoint http://localhost:3000 --email analyst@company.com
# Non-interactive (CI/CD)
vkit login --endpoint https://vaultkit.company.com --email bot@company.com --password $BOT_PASSWORD
vkit whoamiDisplay current user information.
vkit whoami [--format json|table]
Examples:
vkit whoami
vkit whoami --format json
vkit logoutEnd session and clear credentials.
vkit logout
vkit requestSubmit a governed data request using AQL.
vkit request --aql <AQL_JSON> [OPTIONS]
Options:
--aql β AQL JSON payload (inline or via STDIN)--env β Environment (default: production)--requester_region β Your geographic region (e.g., US, EU)--dataset_region β Datasetβs geographic region--requester_clearance β Clearance level: low, high, admin--format β Output format: json, table (default: table)Inline AQL:
vkit request \
--aql '{"source_table":"customers","columns":["email","total_spend"],"limit":100}' \
--requester_region EU \
--dataset_region EU \
--requester_clearance high
AQL via STDIN:
cat query.json | vkit request
# Or
echo '{"source_table":"orders","columns":["order_id","total"]}' | vkit request
AQL from File:
vkit request --aql "$(cat queries/customer_analysis.json)"
Possible Outcomes:
| Outcome | Description | Next Step |
|---|---|---|
| β Granted | Immediate access | vkit fetch --grant <GRANT_ID> |
| β³ Queued | Requires approval | Wait for approval, check with vkit requests list |
| β Denied | Policy disallows | Review policy restrictions |
vkit requests listView your request history.
vkit requests list [--state STATE] [--format FORMAT]
Options:
--state β Filter by state: all, pending, approved, denied (default: all)--format β Output format: json, table (default: table)--limit β Number of results (default: 50)Examples:
# All requests
vkit requests list
# Only pending requests
vkit requests list --state pending
# Approved requests in JSON
vkit requests list --state approved --format json
# Last 100 requests
vkit requests list --limit 100
vkit requests showShow details for a specific request.
vkit requests show <REQUEST_ID>
Example:
vkit requests show req_20240115_xyz789
vkit approval:listList approval requests you are authorized to act on.
vkit approval:list [--state STATE] [--format FORMAT]
Options:
--state β Filter by state: all, pending, approved, denied (default: pending)--format β Output format: json, table (default: table)Examples:
# Pending approvals
vkit approval:list
# All approvals you've handled
vkit approval:list --state all
# JSON output for scripting
vkit approval:list --format json
vkit approval:approveApprove a pending request.
vkit approval:approve <REQUEST_ID> [--ttl SECONDS] [--notes "..."]
Options:
--ttl β Grant lifetime in seconds (default: 3600)--notes β Approval notes (optional)Examples:
# Basic approval
vkit approval:approve 42
# With custom TTL and notes
vkit approval:approve 42 \
--ttl 7200 \
--notes "Approved for Q4 analysis. Limited to aggregate data only."
vkit approval:denyDeny a pending request.
vkit approval:deny <REQUEST_ID> --reason "..."
Options:
--reason β Required explanation for denialExamples:
vkit approval:deny 42 --reason "Insufficient business justification"
vkit approval:deny 42 --reason "Request violates data minimization policy"
vkit fetchFetch data using a previously issued grant.
vkit fetch --grant <GRANT_REF> [--format FORMAT]
Options:
--grant, -g β Grant reference or ID (required)--format β Output format: json, table, csv (default: table)--output, -o β Write to file instead of STDOUTExamples:
# Fetch and display as table
vkit fetch --grant gr_abc123xyz
# Fetch as JSON
vkit fetch --grant gr_abc123xyz --format json
# Fetch and save to CSV
vkit fetch --grant gr_abc123xyz --format csv --output results.csv
# Pipe to jq for processing
vkit fetch --grant gr_abc123xyz --format json | jq '.data[] | select(.revenue > 1000)'
vkit datasource addRegister a new datasource.
vkit datasource add --id <ID> --engine <ENGINE> [OPTIONS]
Options:
--id β Unique datasource identifier (required)--engine β Database engine: postgres, mysql, snowflake, bigquery (required)--username β Database username--password β Database password--config β JSON configuration (host, port, database, etc.)--credential-backend β Secret backend: vaultkit, vault, aws-secretsExamples:
PostgreSQL (Built-in credential storage):
vkit datasource add \
--id production_pg \
--engine postgres \
--username vaultkit_ro \
--password $DB_PASSWORD \
--config '{
"host": "db.production.internal",
"port": 5432,
"database": "analytics",
"ssl_mode": "require",
"connect_timeout": 10
}'
MySQL:
vkit datasource add \
--id production_mysql \
--engine mysql \
--username app_reader \
--password $MYSQL_PASSWORD \
--config '{
"host": "mysql.production.internal",
"port": 3306,
"database": "ecommerce",
"ssl_mode": "REQUIRED"
}'
vkit datasource listList all registered datasources.
vkit datasource list [--format FORMAT]
Examples:
vkit datasource list
vkit datasource list --format json
vkit datasource getGet details for a specific datasource.
vkit datasource get <DATASOURCE_ID>
Example:
vkit datasource get production_pg
vkit datasource testTest connectivity to a datasource.
vkit datasource test <DATASOURCE_ID>
Example:
vkit datasource test production_pg
# Output:
# Testing connection to production_pg...
# β Connection successful
# Engine: PostgreSQL 15.3
# Latency: 45ms
vkit datasource removeRemove a datasource (admin only).
vkit datasource remove <DATASOURCE_ID> [--force]
Options:
--force β Skip confirmation promptExample:
vkit datasource remove old_staging_db --force
vkit scanScan a datasource and detect schema drift.
vkit scan <DATASOURCE_ID> [--mode MODE]
Options:
--mode β Scan mode: diff, apply (default: diff)--format β Output format: json, table (default: table)Modes:
| Mode | Description |
|---|---|
diff |
Show changes without applying (safe, read-only) |
apply |
Update baseline registry with discovered schema |
Examples:
Discover Changes:
vkit scan production_pg
# Output:
# Scanning datasource: production_pg
#
# Schema Drift Detected:
#
# + Dataset: customers
# + Field: phone_number (varchar) [PII] β οΈ NEW - requires policy
# ~ Field: email (text β varchar) [PII] β Already masked
#
# + Dataset: user_sessions
# + Field: ip_address (inet) [PII] β οΈ NEW - requires policy
# + Field: user_agent (text) [INTERNAL] β οΈ NEW - requires policy
#
# Summary: 2 new datasets, 3 new fields, 1 modified field
Apply Changes:
vkit scan production_pg --mode apply
# Output:
# β Baseline registry updated
# Next steps:
# 1. Review new fields: customers.phone_number, user_sessions.ip_address
# 2. Update policies in Git: config/policies/
# 3. Build new bundle: vkit policy bundle
# 4. Deploy bundle: vkit policy deploy
Scan All Datasources:
for ds in $(vkit datasource list --format json | jq -r '.[].id'); do
echo "Scanning $ds..."
vkit scan $ds
done
vkit policy bundleCompile policies and registry into a deployable bundle.
vkit policy bundle [OPTIONS]
Options:
--policies_dir β Path to policies directory (default: config/policies)--registry_dir β Path to registry files (default: config)--datasources_dir β Path to datasource configs (default: config/datasources)--out β Output bundle file (default: dist/policy_bundle.json)--org β Organization identifier (optional, defaults to logged-in userβs org)Example:
# Using logged-in user's org
vkit policy bundle \
--policies_dir config/policies \
--registry_dir config \
--datasources_dir config/datasources \
--out dist/policy_bundle.json
# Specifying org explicitly
vkit policy bundle \
--policies_dir config/policies \
--registry_dir config \
--datasources_dir config/datasources \
--out dist/policy_bundle.json \
--org acme
vkit policy validateValidate a policy bundle without deploying.
vkit policy validate --bundle <BUNDLE_FILE>
Example:
vkit policy validate --bundle dist/policy_bundle.json
# Output:
# Validating policy bundle...
# β Schema validation passed
# β Policy syntax valid
# β No circular dependencies
# β All datasources referenced
# Bundle is valid and ready to deploy
vkit policy deployDeploy a policy bundle to the control plane.
vkit policy deploy --bundle <BUNDLE_FILE> [OPTIONS]
Options:
--bundle β Path to bundle file (required)--org β Organization identifier (optional, defaults to logged-in userβs org)--activate β Immediately activate bundle--dry-run β Validate deployment without activatingExamples:
# Deploy and activate (using logged-in user's org)
vkit policy deploy \
--bundle dist/policy_bundle.json \
--activate
# Deploy with explicit org
vkit policy deploy \
--bundle dist/policy_bundle.json \
--org acme \
--activate
# Dry run (test deployment)
vkit policy deploy \
--bundle dist/policy_bundle.json \
--dry-run
vkit policy listList active policy bundles.
vkit policy list
vkit policy showShow details of a specific policy.
vkit policy show <POLICY_ID>
vkit audit querySearch audit logs.
vkit audit query [OPTIONS]
Options:
--user β Filter by user email--action β Filter by action: granted, denied, pending--dataset β Filter by dataset name--days β Look back N days (default: 7)--limit β Number of results (default: 100)--format β Output format: json, table, csvExamples:
# All queries by a user
vkit audit query --user analyst@company.com --days 30
# Denied access attempts
vkit audit query --action denied --days 7
# Access to specific dataset
vkit audit query --dataset customers --action granted
# Export to CSV
vkit audit query --user analyst@company.com --format csv --output audit_report.csv
vkit audit exportExport audit logs for compliance reporting.
vkit audit export --start-date <DATE> --end-date <DATE> [OPTIONS]
Options:
--start-date β Start date (YYYY-MM-DD)--end-date β End date (YYYY-MM-DD)--format β Output format: json, csv (default: csv)--output β Output file pathExample:
vkit audit export \
--start-date 2024-01-01 \
--end-date 2024-01-31 \
--format csv \
--output compliance_reports/january_2024.csv
Batch Request Processing:
#!/bin/bash
# process_requests.sh
REQUESTS=(
'{"source_table":"customers","columns":["id","email"],"limit":100}'
'{"source_table":"orders","columns":["order_id","total"],"limit":100}'
'{"source_table":"products","columns":["product_id","name"],"limit":100}'
)
for aql in "${REQUESTS[@]}"; do
echo "Processing: $aql"
vkit request --aql "$aql" --format json | jq -r '.grant_id' >> grants.txt
done
echo "Generated grants:"
cat grants.txt
Automated Approvals (for testing):
#!/bin/bash
# auto_approve_pending.sh
PENDING=$(vkit approval:list --state pending --format json)
echo "$PENDING" | jq -r '.[].id' | while read -r request_id; do
echo "Approving request: $request_id"
vkit approval:approve "$request_id" --ttl 3600 --notes "Auto-approved for testing"
done
GitHub Actions Example:
name: Deploy VaultKit Policies
on:
push:
branches: [main]
paths:
- 'config/policies/**'
- 'config/registry.yaml'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install vkit CLI
run: gem install vaultkitcli
- name: Authenticate
run: |
vkit login \
--endpoint $ \
--email $ \
--password $
- name: Build Policy Bundle
run: |
vkit policy bundle \
--policies_dir config/policies \
--registry_dir config \
--out policy_bundle.json \
--org $
- name: Validate Bundle
run: vkit policy validate --bundle policy_bundle.json
- name: Deploy Bundle
run: |
vkit policy deploy \
--bundle policy_bundle.json \
--org $ \
--activate
Extract specific fields:
vkit requests list --format json | jq '.[] | select(.state == "approved") | {id, dataset, requester}'
Count requests by state:
vkit requests list --format json | jq 'group_by(.state) | map({state: .[0].state, count: length})'
Find high-value transactions:
vkit fetch --grant gr_abc123 --format json | jq '.data[] | select(.amount > 10000)'
Problem:
Error: Authentication failed (401 Unauthorized)
Solutions:
# 1. Check endpoint
echo $VKIT_API_URL
# 2. Re-authenticate
vkit logout
vkit login --endpoint http://localhost:3000 --email you@company.com
# 3. Verify credentials
vkit whoami
Problem:
Error: Connection refused - connect(2) for "localhost" port 3000
Solutions:
# 1. Check if control plane is running
curl http://localhost:3000/health
# 2. Verify Docker containers
cd infra
docker compose ps
# 3. Start services
docker compose up
Problem:
Error: Grant has expired
Grant ID: gr_abc123xyz
Expired at: 2024-01-15 12:00:00 UTC
Solutions:
# 1. Request new grant
vkit request --aql '{"source_table":"customers",...}'
# 2. Request longer TTL (if approval required)
vkit request --aql '{...}' --ttl 7200
Problem:
β Request denied
Reason: Cross-region PII access forbidden
Policy: gdpr_protection
Solutions:
Enable verbose logging:
# Set debug environment variable
export VKIT_DEBUG=true
# Run command
vkit request --aql '{...}'
# Output includes:
# - HTTP request/response details
# - Policy evaluation trace
# - Timing information
Verify CLI and control plane connectivity:
# Check CLI version
vkit --version
# Check control plane health
curl $VKIT_API_URL/health
# Test authentication
vkit whoami
We welcome contributions to the VaultKit CLI!
# Clone repository
git clone https://github.com/yourorg/vaultkit-cli.git
cd vaultkit-cli
# Install dependencies
bundle install
# Run tests
bundle exec rspec
# Run CLI locally
bundle exec bin/vkit --help
# Unit tests
bundle exec rspec spec/unit
# Integration tests (requires running control plane)
bundle exec rspec spec/integration
# All tests
bundle exec rspec
# Run RuboCop
bundle exec rubocop
# Auto-fix issues
bundle exec rubocop -a
VaultKit CLI is licensed under the Apache License 2.0. See LICENSE for details.
Built with β€οΈ by the VaultKit team