vaultkit 0.1.1 โ†’ 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34fa800a34471c3f3b5c33ac0a6d422eaa7bb1371fe432094fda2b4cf19d6686
4
- data.tar.gz: eacac1644c5598c4ad819e3d5ddb8cb029a73749dd78f55d9b9bd890bf769d61
3
+ metadata.gz: 78b1d315e88a305ca599630dcb679921c4b7feb9cf6126892a845da8afc05895
4
+ data.tar.gz: 5cb8b0aacc91385d26a681a5ab9725f260166952cfe190de7bfa47353e1b2fd6
5
5
  SHA512:
6
- metadata.gz: 5cb6321bac94a278f7e74deafda228bc4e544a240e318a2fcd6765678e6191485e25767dee7cb342c428c1bd3bf36d68dd3d4905ac84b6266910db6a86bdfbee
7
- data.tar.gz: 7416063b5dd6ad13bbe4d617dc97d925429594061f3857180296093d0f3089c9be0bd3afb5a61540e4850d2d1a81a8205c6276aa871ba0ff2da57d10a19412a3
6
+ metadata.gz: f123babdc6fea12f1e7a3adaa08a89d1181f82c0b11dfd73171d3a82a84680c9f68e55f2e724a02a232f34c2b8bdeea31c31f8e4a49a045dcccebb710daf3ad4
7
+ data.tar.gz: 8ddfea885a78988b1c0cd74d6735364f5aab63d7312a639154956dd6e928035f5128b22fe12ccf422ccb9e7d5e45cb251a521dc6ab285bc011abd29b6b2bddb7
data/README.md CHANGED
@@ -27,7 +27,12 @@ The VaultKit CLI (`vkit`) is the primary interface for interacting with the Vaul
27
27
 
28
28
  ## ๐ŸŽฏ What is VaultKit CLI?
29
29
 
30
- The VaultKit CLI provides command-line access to:
30
+ The VaultKit CLI provides command-line access to VaultKit for:
31
+
32
+ - **Users** - Data analysts, engineers, and administrators
33
+ - **AI Agents** - LLMs and autonomous systems requiring governed data access
34
+ - **Tools & Services** - CI/CD pipelines, data pipelines, and automated workflows
35
+ - **Applications** - Programmatic integration via scripting
31
36
 
32
37
  | Capability | Description |
33
38
  |------------|-------------|
@@ -73,16 +78,6 @@ VaultKit uses a **request โ†’ policy โ†’ grant โ†’ fetch** workflow:
73
78
  gem install vaultkitcli
74
79
  ```
75
80
 
76
- ### Option 2: Install from Source
77
-
78
- ```bash
79
- git clone https://github.com/yourorg/vaultkit-cli.git
80
- cd vaultkit-cli
81
- bundle install
82
- gem build vaultkitcli.gemspec
83
- gem install ./vaultkitcli-0.1.0.gem
84
- ```
85
-
86
81
  ### Verify Installation
87
82
 
88
83
  ```bash
@@ -129,7 +124,7 @@ vkit request --aql '{
129
124
 
130
125
  If granted immediately:
131
126
  ```bash
132
- vkit fetch --grant g_customers_abc123xyz
127
+ vkit fetch --grant gr_abc123xyz
133
128
  ```
134
129
 
135
130
  If approval required:
@@ -138,7 +133,7 @@ If approval required:
138
133
  vkit requests list --state pending
139
134
 
140
135
  # After approval
141
- vkit fetch --grant g_customers_abc123xyz
136
+ vkit fetch --grant gr_abc123xyz
142
137
  ```
143
138
 
144
139
  ---
@@ -180,12 +175,21 @@ vkit whoami
180
175
 
181
176
  **Output:**
182
177
  ```
183
- User ID: user_12345
184
- Email: analyst@company.com
185
- Role: analyst
186
- Clearance Level: 2 (high)
187
- Region: US
188
- Session Expires: 2024-01-15 18:00:00 UTC
178
+ ๐Ÿ‘ค analyst@acme.com (role: analyst, org: acme)
179
+ ```
180
+
181
+ **JSON Format:**
182
+ ```bash
183
+ vkit whoami --format json
184
+ ```
185
+
186
+ **Output:**
187
+ ```json
188
+ {
189
+ "email": "analyst@acme.com",
190
+ "role": "analyst",
191
+ "org": "acme"
192
+ }
189
193
  ```
190
194
 
191
195
  ### `vkit logout`
@@ -212,12 +216,12 @@ vkit request --aql '{
212
216
 
213
217
  # Output:
214
218
  # โœ“ Request granted immediately
215
- # Grant ID: g_customers_abc123xyz
219
+ # Grant ID: gr_abc123xyz
216
220
  # TTL: 4 hours
217
- # Use: vkit fetch --grant g_customers_abc123xyz
221
+ # Use: vkit fetch --grant gr_abc123xyz
218
222
 
219
223
  # 2. Fetch data
220
- vkit fetch --grant g_customers_abc123xyz --format table
224
+ vkit fetch --grant gr_abc123xyz --format table
221
225
  ```
222
226
 
223
227
  ### Workflow 2: Approval Required
@@ -241,7 +245,7 @@ vkit request --aql '{
241
245
  vkit requests list --state pending
242
246
 
243
247
  # 3. After approval, fetch data
244
- vkit fetch --grant g_customers_approved_abc123
248
+ vkit fetch --grant gr_approved_abc123
245
249
  ```
246
250
 
247
251
  ### Workflow 3: Denied Access
@@ -491,16 +495,16 @@ vkit fetch --grant <GRANT_REF> [--format FORMAT]
491
495
  **Examples:**
492
496
  ```bash
493
497
  # Fetch and display as table
494
- vkit fetch --grant g_customers_abc123xyz
498
+ vkit fetch --grant gr_abc123xyz
495
499
 
496
500
  # Fetch as JSON
497
- vkit fetch --grant g_customers_abc123xyz --format json
501
+ vkit fetch --grant gr_abc123xyz --format json
498
502
 
499
503
  # Fetch and save to CSV
500
- vkit fetch --grant g_customers_abc123xyz --format csv --output results.csv
504
+ vkit fetch --grant gr_abc123xyz --format csv --output results.csv
501
505
 
502
506
  # Pipe to jq for processing
503
- vkit fetch --grant g_customers_abc123xyz --format json | jq '.data[] | select(.revenue > 1000)'
507
+ vkit fetch --grant gr_abc123xyz --format json | jq '.data[] | select(.revenue > 1000)'
504
508
  ```
505
509
 
506
510
  ---
@@ -525,7 +529,7 @@ vkit datasource add --id <ID> --engine <ENGINE> [OPTIONS]
525
529
 
526
530
  **Examples:**
527
531
 
528
- **PostgreSQL:**
532
+ **PostgreSQL (Built-in credential storage):**
529
533
  ```bash
530
534
  vkit datasource add \
531
535
  --id production_pg \
@@ -541,33 +545,18 @@ vkit datasource add \
541
545
  }'
542
546
  ```
543
547
 
544
- **With HashiCorp Vault:**
548
+ **MySQL:**
545
549
  ```bash
546
550
  vkit datasource add \
547
- --id production_pg \
548
- --engine postgres \
549
- --credential-backend vault \
550
- --vault-path secret/data/databases/production \
551
+ --id production_mysql \
552
+ --engine mysql \
553
+ --username app_reader \
554
+ --password $MYSQL_PASSWORD \
551
555
  --config '{
552
- "host": "db.production.internal",
553
- "port": 5432,
554
- "database": "analytics",
555
- "ssl_mode": "verify-full"
556
- }'
557
- ```
558
-
559
- **Snowflake:**
560
- ```bash
561
- vkit datasource add \
562
- --id snowflake_prod \
563
- --engine snowflake \
564
- --username analytics_user \
565
- --password $SNOWFLAKE_PASSWORD \
566
- --config '{
567
- "account": "xy12345.us-east-1",
568
- "warehouse": "ANALYTICS_WH",
569
- "database": "PRODUCTION",
570
- "schema": "PUBLIC"
556
+ "host": "mysql.production.internal",
557
+ "port": 3306,
558
+ "database": "ecommerce",
559
+ "ssl_mode": "REQUIRED"
571
560
  }'
572
561
  ```
573
562
 
@@ -630,7 +619,7 @@ vkit datasource remove <DATASOURCE_ID> [--force]
630
619
 
631
620
  **Example:**
632
621
  ```bash
633
- vkit datasource remove old_staging_customers_db --force
622
+ vkit datasource remove old_staging_db --force
634
623
  ```
635
624
 
636
625
  ---
@@ -716,10 +705,18 @@ vkit policy bundle [OPTIONS]
716
705
  - `--registry_dir` โ€” Path to registry files (default: `config`)
717
706
  - `--datasources_dir` โ€” Path to datasource configs (default: `config/datasources`)
718
707
  - `--out` โ€” Output bundle file (default: `dist/policy_bundle.json`)
719
- - `--org` โ€” Organization identifier
708
+ - `--org` โ€” Organization identifier (optional, defaults to logged-in user's org)
720
709
 
721
710
  **Example:**
722
711
  ```bash
712
+ # Using logged-in user's org
713
+ vkit policy bundle \
714
+ --policies_dir config/policies \
715
+ --registry_dir config \
716
+ --datasources_dir config/datasources \
717
+ --out dist/policy_bundle.json
718
+
719
+ # Specifying org explicitly
723
720
  vkit policy bundle \
724
721
  --policies_dir config/policies \
725
722
  --registry_dir config \
@@ -759,13 +756,18 @@ vkit policy deploy --bundle <BUNDLE_FILE> [OPTIONS]
759
756
 
760
757
  **Options:**
761
758
  - `--bundle` โ€” Path to bundle file (required)
762
- - `--org` โ€” Organization identifier
759
+ - `--org` โ€” Organization identifier (optional, defaults to logged-in user's org)
763
760
  - `--activate` โ€” Immediately activate bundle
764
761
  - `--dry-run` โ€” Validate deployment without activating
765
762
 
766
763
  **Examples:**
767
764
  ```bash
768
- # Deploy and activate
765
+ # Deploy and activate (using logged-in user's org)
766
+ vkit policy deploy \
767
+ --bundle dist/policy_bundle.json \
768
+ --activate
769
+
770
+ # Deploy with explicit org
769
771
  vkit policy deploy \
770
772
  --bundle dist/policy_bundle.json \
771
773
  --org acme \
@@ -774,7 +776,6 @@ vkit policy deploy \
774
776
  # Dry run (test deployment)
775
777
  vkit policy deploy \
776
778
  --bundle dist/policy_bundle.json \
777
- --org acme \
778
779
  --dry-run
779
780
  ```
780
781
 
@@ -854,69 +855,6 @@ vkit audit export \
854
855
 
855
856
  ---
856
857
 
857
- ## โš™๏ธ Configuration
858
-
859
- ### Configuration File
860
-
861
- Create `~/.vkit/config.yaml` for persistent settings:
862
-
863
- ```yaml
864
- # VaultKit Control Plane
865
- api_url: "https://vaultkit.company.com"
866
-
867
- # Authentication
868
- auth:
869
- method: "sso" # or "password"
870
- sso_provider: "okta"
871
-
872
- # Default Settings
873
- defaults:
874
- datasource: "production_pg"
875
- environment: "production"
876
- requester_region: "US"
877
- clearance_level: "high"
878
-
879
- # Output Preferences
880
- output:
881
- format: "table" # json, table, csv
882
- color: true
883
-
884
- # Audit Logging
885
- audit:
886
- local_log: true
887
- log_customers_path: "~/.vkit/audit.log"
888
-
889
- # Request Settings
890
- request:
891
- default_ttl: 3600 # 1 hour
892
- auto_retry: true
893
- retry_attempts: 3
894
- ```
895
-
896
- ### Environment Variables
897
-
898
- Override config file with environment variables:
899
-
900
- ```bash
901
- # Required
902
- export VKIT_API_URL="https://vaultkit.company.com"
903
-
904
- # Optional
905
- export VKIT_CONFIg_customers_PATH="~/.vkit/config.yaml"
906
- export VKIT_AUTH_TOKEN="eyJhbGciOiJIUzI1NiIs..."
907
- export VKIT_DEFAULT_DATASOURCE="production_pg"
908
- export VKIT_OUTPUT_FORMAT="json"
909
- ```
910
-
911
- ### Precedence Order
912
-
913
- 1. Command-line flags (highest priority)
914
- 2. Environment variables
915
- 3. Configuration file
916
- 4. Built-in defaults (lowest priority)
917
-
918
- ---
919
-
920
858
  ## ๐Ÿ”ฌ Advanced Usage
921
859
 
922
860
  ### Scripting with vkit
@@ -992,7 +930,7 @@ jobs:
992
930
  --policies_dir config/policies \
993
931
  --registry_dir config \
994
932
  --out policy_bundle.json \
995
- --org ${{ secrets.ORg_customers_ID }}
933
+ --org ${{ secrets.ORG_ID }}
996
934
 
997
935
  - name: Validate Bundle
998
936
  run: vkit policy validate --bundle policy_bundle.json
@@ -1001,7 +939,7 @@ jobs:
1001
939
  run: |
1002
940
  vkit policy deploy \
1003
941
  --bundle policy_bundle.json \
1004
- --org ${{ secrets.ORg_customers_ID }} \
942
+ --org ${{ secrets.ORG_ID }} \
1005
943
  --activate
1006
944
  ```
1007
945
 
@@ -1019,7 +957,7 @@ vkit requests list --format json | jq 'group_by(.state) | map({state: .[0].state
1019
957
 
1020
958
  **Find high-value transactions:**
1021
959
  ```bash
1022
- vkit fetch --grant g_customers_abc123 --format json | jq '.data[] | select(.amount > 10000)'
960
+ vkit fetch --grant gr_abc123 --format json | jq '.data[] | select(.amount > 10000)'
1023
961
  ```
1024
962
 
1025
963
  ---
@@ -1073,7 +1011,7 @@ docker compose up
1073
1011
  **Problem:**
1074
1012
  ```
1075
1013
  Error: Grant has expired
1076
- Grant ID: g_customers_abc123xyz
1014
+ Grant ID: gr_abc123xyz
1077
1015
  Expired at: 2024-01-15 12:00:00 UTC
1078
1016
  ```
1079
1017
 
@@ -1183,7 +1121,7 @@ bundle exec rubocop -a
1183
1121
 
1184
1122
  ## ๐Ÿ“š Additional Resources
1185
1123
 
1186
- - **Main Repository**: [github.com/yourorg/vaultkit](https://github.com/yourorg/vaultkit)
1124
+ - **Main Repository**: [github.com/ndbaba1/vaultkitcli.git](https://github.com/ndbaba1/vaultkitcli.git)
1187
1125
  - **Documentation**: [docs.vaultkit.io](https://docs.vaultkit.io)
1188
1126
  - **AQL Specification**: [docs.vaultkit.io/aql](https://docs.vaultkit.io/aql)
1189
1127
  - **Policy Reference**: [docs.vaultkit.io/policies](https://docs.vaultkit.io/policies)
@@ -1197,13 +1135,4 @@ VaultKit CLI is licensed under the Apache License 2.0. See [LICENSE](LICENSE) fo
1197
1135
 
1198
1136
  ---
1199
1137
 
1200
- ## ๐Ÿ’ฌ Support
1201
-
1202
- - **Issues**: [github.com/yourorg/vaultkit-cli/issues](https://github.com/yourorg/vaultkit-cli/issues)
1203
- - **Discussions**: [github.com/yourorg/vaultkit-cli/discussions](https://github.com/yourorg/vaultkit-cli/discussions)
1204
- - **Email**: support@vaultkit.io
1205
- - **Slack**: [vaultkit.slack.com](https://vaultkit.slack.com)
1206
-
1207
- ---
1208
-
1209
1138
  **Built with โค๏ธ by the VaultKit team**
@@ -31,7 +31,7 @@ module Vkit
31
31
  result =
32
32
  case auth
33
33
  when "oidc"
34
- oidc_flow(client, discovery["oidc"]["login_url"])
34
+ oidc_flow(client)
35
35
  when "password"
36
36
  password_flow(client)
37
37
  when "token"
@@ -55,20 +55,20 @@ module Vkit
55
55
 
56
56
  private
57
57
 
58
- def oidc_flow(client, login_url)
58
+ def oidc_flow(client)
59
59
  start = client.start_cli_login
60
60
  poll_token = start["poll_token"]
61
-
61
+ login_url = start["login_url"]
62
+
62
63
  open_browser(login_url)
63
64
  puts "โณ Waiting for authentication to complete..."
64
-
65
+
65
66
  loop do
66
67
  res = client.poll_cli_login(poll_token)
67
-
68
+
68
69
  case res.code.to_i
69
70
  when 204
70
71
  sleep 2
71
- next
72
72
  when 200
73
73
  body = JSON.parse(res.body)
74
74
  return {
@@ -83,7 +83,7 @@ module Vkit
83
83
  raise "Unexpected response: #{res.code}"
84
84
  end
85
85
  end
86
- end
86
+ end
87
87
 
88
88
  def password_flow(client)
89
89
  email = @email || prompt("Email")
@@ -3,6 +3,21 @@ module Vkit
3
3
  module Commands
4
4
  class LogoutCommand < BaseCommand
5
5
  def call
6
+ token = credential_store.token
7
+
8
+ if token
9
+ begin
10
+ client = Vkit::Core::AuthClient.new(
11
+ base_url: credential_store.endpoint
12
+ )
13
+
14
+ client.logout(token)
15
+ rescue => e
16
+ warn "โš ๏ธ Server logout failed: #{e.message}"
17
+ warn "โš ๏ธ Continuing with local logout"
18
+ end
19
+ end
20
+
6
21
  credential_store.clear_token!
7
22
  puts "๐Ÿงน Logged out"
8
23
  end
@@ -3,10 +3,40 @@ module Vkit
3
3
  module Commands
4
4
  class WhoamiCommand < BaseCommand
5
5
  def call
6
- with_auth do
7
- user = credential_store.user
8
- puts "๐Ÿ‘ค #{user['email']} (role: #{user['role']}, org: #{user['organization_slug']})"
9
- end
6
+ user = fetch_user_from_server_or_fallback
7
+
8
+ puts "๐Ÿ‘ค #{user['email']} " \
9
+ "(role: #{user['role']}, org: #{user['organization_slug']})"
10
+ end
11
+
12
+ private
13
+
14
+ def fetch_user_from_server_or_fallback
15
+ token = credential_store.token
16
+ endpoint = credential_store.endpoint
17
+
18
+ raise "Not logged in" if token.nil? || endpoint.nil?
19
+
20
+ client = Vkit::Core::AuthClient.new(base_url: endpoint)
21
+ server_user = client.whoami(token)
22
+
23
+ # keep cache in sync if server is authoritative
24
+ credential_store.save_user(server_user)
25
+
26
+ server_user
27
+ rescue => e
28
+ fallback_local_user(e)
29
+ end
30
+
31
+ def fallback_local_user(error)
32
+ user = credential_store.user
33
+ raise "Not logged in" if user.nil?
34
+
35
+ warn "โš ๏ธ Unable to verify identity with server"
36
+ warn "โš ๏ธ #{error.message}"
37
+ warn "โš ๏ธ Showing cached identity"
38
+
39
+ user
10
40
  end
11
41
  end
12
42
  end
@@ -29,11 +29,15 @@ module Vkit
29
29
  end
30
30
 
31
31
  def poll_cli_login(poll_token)
32
- uri = uri_for("/auth/cli/poll?token=#{poll_token}")
33
- req = Net::HTTP::Get.new(uri)
34
-
32
+ uri = uri_for("/auth/cli/poll")
33
+ req = Net::HTTP::Post.new(uri)
34
+ req["Content-Type"] = "application/json"
35
+ req.body = JSON.dump(
36
+ poll_token: poll_token
37
+ )
38
+
35
39
  http_request(uri, req, allow_non_200: true)
36
- end
40
+ end
37
41
 
38
42
  def password_login(email:, password:)
39
43
  uri = uri_for("/api/users/sign_in")
@@ -66,6 +70,14 @@ module Vkit
66
70
  body["user"]
67
71
  end
68
72
 
73
+ def logout(token)
74
+ uri = uri_for("/api/users/sign_out")
75
+ req = Net::HTTP::Delete.new(uri)
76
+ req["Authorization"] = "Bearer #{token}"
77
+
78
+ http_request(uri, req, allow_non_200: true)
79
+ end
80
+
69
81
  private
70
82
 
71
83
  def uri_for(path)
@@ -33,6 +33,22 @@ module Vkit
33
33
  true
34
34
  end
35
35
 
36
+ def save_user(user)
37
+ payload = load_payload
38
+ return unless payload
39
+
40
+ payload["user"] = user
41
+
42
+ case
43
+ when mac?
44
+ mac_keychain_store(payload)
45
+ when linux? && secret_tool_available?
46
+ linux_secret_service_store(payload)
47
+ else
48
+ file_store(payload)
49
+ end
50
+ end
51
+
36
52
  def endpoint
37
53
  load_payload&.dig("endpoint")
38
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaultkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nnamdi Ogundu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-05 00:00:00.000000000 Z
11
+ date: 2026-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor