keeper_secrets_manager 17.0.3 → 17.0.4
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 +4 -4
- data/DEVELOPER_SETUP.md +0 -0
- data/MANUAL_TESTING_GUIDE.md +332 -0
- data/RUBY_SDK_COMPLETE_DOCUMENTATION.md +354 -0
- data/RUBY_SDK_COMPREHENSIVE_SUMMARY.md +192 -0
- data/examples/01_quick_start.rb +45 -0
- data/examples/02_authentication.rb +82 -0
- data/examples/03_retrieve_secrets.rb +81 -0
- data/examples/04_create_update_delete.rb +104 -0
- data/examples/05_field_types.rb +135 -0
- data/examples/06_files.rb +137 -0
- data/examples/07_folders.rb +145 -0
- data/examples/08_notation.rb +103 -0
- data/examples/09_totp.rb +100 -0
- data/examples/README.md +89 -0
- data/lib/keeper_secrets_manager/version.rb +1 -1
- metadata +15 -12
- data/examples/basic_usage.rb +0 -139
- data/examples/config_string_example.rb +0 -99
- data/examples/debug_secrets.rb +0 -84
- data/examples/demo_list_secrets.rb +0 -182
- data/examples/download_files.rb +0 -100
- data/examples/flexible_records_example.rb +0 -94
- data/examples/folder_hierarchy_demo.rb +0 -109
- data/examples/full_demo.rb +0 -176
- data/examples/my_test_standalone.rb +0 -176
- data/examples/simple_test.rb +0 -162
- data/examples/storage_examples.rb +0 -126
@@ -1,126 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Add the Ruby SDK to the load path
|
4
|
-
$LOAD_PATH.unshift('/Users/mustinov/Source/secrets-manager/sdk/ruby/lib')
|
5
|
-
|
6
|
-
require 'keeper_secrets_manager'
|
7
|
-
require 'json'
|
8
|
-
|
9
|
-
puts "=== Keeper Secrets Manager Storage Examples ==="
|
10
|
-
|
11
|
-
# Your one-time token (replace with a fresh one)
|
12
|
-
TOKEN = 'US:YOUR_ONE_TIME_TOKEN_HERE'
|
13
|
-
|
14
|
-
puts "\n1. One-time token (no storage) - Token used every time"
|
15
|
-
puts "=" * 50
|
16
|
-
begin
|
17
|
-
# This uses the token directly and doesn't save credentials
|
18
|
-
sm = KeeperSecretsManager.new(token: TOKEN)
|
19
|
-
secrets = sm.get_secrets()
|
20
|
-
puts "✓ Connected and found #{secrets.length} secrets"
|
21
|
-
rescue => e
|
22
|
-
puts "✗ Error: #{e.message}"
|
23
|
-
end
|
24
|
-
|
25
|
-
puts "\n2. In-Memory Storage - Credentials stored in memory"
|
26
|
-
puts "=" * 50
|
27
|
-
begin
|
28
|
-
# Create in-memory storage
|
29
|
-
storage = KeeperSecretsManager::Storage::InMemoryStorage.new
|
30
|
-
|
31
|
-
# First connection with token
|
32
|
-
puts "First connection (with token)..."
|
33
|
-
sm1 = KeeperSecretsManager.new(token: TOKEN, config: storage)
|
34
|
-
secrets1 = sm1.get_secrets()
|
35
|
-
puts "✓ Found #{secrets1.length} secrets"
|
36
|
-
|
37
|
-
# Get the config as JSON for later use
|
38
|
-
config_json = storage.to_json
|
39
|
-
puts "✓ Config saved to memory (length: #{config_json.length} chars)"
|
40
|
-
|
41
|
-
# Subsequent connections without token - just pass the config!
|
42
|
-
puts "\nSecond connection (no token needed)..."
|
43
|
-
new_storage = KeeperSecretsManager::Storage::InMemoryStorage.new(config_json)
|
44
|
-
sm2 = KeeperSecretsManager.new(config: new_storage)
|
45
|
-
secrets2 = sm2.get_secrets()
|
46
|
-
puts "✓ Found #{secrets2.length} secrets using stored credentials"
|
47
|
-
|
48
|
-
# Or use base64 encoded config
|
49
|
-
puts "\nThird connection (using base64 config)..."
|
50
|
-
config_base64 = Base64.strict_encode64(config_json)
|
51
|
-
storage_from_b64 = KeeperSecretsManager::Storage::InMemoryStorage.new(config_base64)
|
52
|
-
sm3 = KeeperSecretsManager.new(config: storage_from_b64)
|
53
|
-
secrets3 = sm3.get_secrets()
|
54
|
-
puts "✓ Found #{secrets3.length} secrets using base64 config"
|
55
|
-
|
56
|
-
rescue => e
|
57
|
-
puts "✗ Error: #{e.message}"
|
58
|
-
end
|
59
|
-
|
60
|
-
puts "\n3. File Storage - Credentials saved to disk"
|
61
|
-
puts "=" * 50
|
62
|
-
begin
|
63
|
-
# Create file storage
|
64
|
-
config_file = 'keeper_config.json'
|
65
|
-
file_storage = KeeperSecretsManager::Storage::FileStorage.new(config_file)
|
66
|
-
|
67
|
-
# First connection with token
|
68
|
-
puts "First connection (with token)..."
|
69
|
-
sm1 = KeeperSecretsManager.new(token: TOKEN, config: file_storage)
|
70
|
-
secrets1 = sm1.get_secrets()
|
71
|
-
puts "✓ Found #{secrets1.length} secrets"
|
72
|
-
puts "✓ Credentials saved to #{config_file}"
|
73
|
-
|
74
|
-
# Later, in a different script/session
|
75
|
-
puts "\nSimulating new session..."
|
76
|
-
file_storage2 = KeeperSecretsManager::Storage::FileStorage.new(config_file)
|
77
|
-
sm2 = KeeperSecretsManager.new(config: file_storage2)
|
78
|
-
secrets2 = sm2.get_secrets()
|
79
|
-
puts "✓ Found #{secrets2.length} secrets using saved credentials"
|
80
|
-
|
81
|
-
# Clean up
|
82
|
-
File.delete(config_file) if File.exist?(config_file)
|
83
|
-
puts "✓ Cleaned up config file"
|
84
|
-
|
85
|
-
rescue => e
|
86
|
-
puts "✗ Error: #{e.message}"
|
87
|
-
end
|
88
|
-
|
89
|
-
puts "\n4. Pre-populated Storage - Manual configuration"
|
90
|
-
puts "=" * 50
|
91
|
-
begin
|
92
|
-
# You can manually populate storage with known values
|
93
|
-
manual_storage = KeeperSecretsManager::Storage::InMemoryStorage.new
|
94
|
-
|
95
|
-
# These would come from your secure configuration
|
96
|
-
manual_storage.save_string('hostname', 'keepersecurity.com')
|
97
|
-
manual_storage.save_string('clientId', 'YOUR_CLIENT_ID')
|
98
|
-
manual_storage.save_bytes('appKey', Base64.decode64('YOUR_APP_KEY_BASE64'))
|
99
|
-
manual_storage.save_bytes('privateKey', Base64.decode64('YOUR_PRIVATE_KEY_BASE64'))
|
100
|
-
# ... other required keys
|
101
|
-
|
102
|
-
# Connect using pre-configured storage
|
103
|
-
# sm = KeeperSecretsManager.new(config: manual_storage)
|
104
|
-
puts "✓ Manual storage example (commented out - needs real credentials)"
|
105
|
-
|
106
|
-
rescue => e
|
107
|
-
puts "✗ Error: #{e.message}"
|
108
|
-
end
|
109
|
-
|
110
|
-
puts "\n5. Environment Variable Storage"
|
111
|
-
puts "=" * 50
|
112
|
-
puts "You can also load from environment variables:"
|
113
|
-
puts <<-EOF
|
114
|
-
# Set environment variable with base64 config
|
115
|
-
export KSM_CONFIG="eyJjbGllbnRJZCI6Ii4uLiJ9..."
|
116
|
-
|
117
|
-
# SDK will automatically use it
|
118
|
-
sm = KeeperSecretsManager.new()
|
119
|
-
EOF
|
120
|
-
|
121
|
-
puts "\nKey Points:"
|
122
|
-
puts "- One-time tokens can only be used once"
|
123
|
-
puts "- In-memory storage is lost when program exits"
|
124
|
-
puts "- File storage persists credentials between runs"
|
125
|
-
puts "- Always protect stored credentials appropriately"
|
126
|
-
puts "- Use file permissions to secure config files"
|