Implement Vault secret cache system
New scripts: - vault-cache.sh: Main cache manager (sync/get/list/status/invalidate) - vault-env.sh: Sourceable environment with quick accessor functions - vault-api-cached.sh: Drop-in replacement for vault_api.sh using cache - nocodb-api.sh: NocoDB API wrapper using cached token - qdrant-api.sh: Qdrant API wrapper using cached key - README-vault-cache.md: Documentation Updated scripts: - vault_grist_api.sh: Now uses vault cache - checks/check-memory-table.sh: Uses vault cache - utils/get-columns.sh: Uses vault cache - utils/update-type-col.sh: Uses vault cache Features: - 29 secrets cached from Vault (6 categories) - Auto-refresh on stale entries (1hr TTL) - Vault token cached for 24h - Restricted permissions (700/600) on cache files - Fallback to direct Vault API if cache miss
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Get vault token
|
||||
VAULT_RESP=$(curl -sk -X POST \
|
||||
-d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' \
|
||||
"https://beavault.beawit.net:8200/v1/auth/approle/login")
|
||||
# check-memory-table.sh - Test NocoDB memory table access
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(echo "$VAULT_RESP" | jq -r '.auth.client_token')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
# Get nocodb token
|
||||
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" \
|
||||
"https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure" | \
|
||||
jq -r '.data.data["nocodb-token"]')
|
||||
NOCODB_TOKEN=$(vault_nocodb_token)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token from vault cache"
|
||||
echo "Run: ${SCRIPT_DIR}/../vault-cache.sh sync"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Token: ${NOCODB_TOKEN:0:20}..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user