All NocoDB/Grist API scripts now use vault-env.sh instead of direct Vault queries: Updated scripts: - checks/check-agent.sh - checks/check-memory-table.sh (already done) - fixes/fix-columns.sh - fixes/fix-severity-status.sh - fixes/fix-status-col.sh - fixes/fix-status-only.sh - fixes/fix-type-col.sh - fixes/fix-type-options.sh - fixes/fix-type-v2.sh - utils/debug-coloptions.sh - utils/get-col-id.sh - utils/get-columns.sh (already done) - utils/recreate-type-column.sh - utils/update-column-options.sh - utils/update-type-col.sh (already done) - get_grist_token.sh - grist_api.sh - refresh_tokens.sh - store_grist_token.sh - update_survey_dates.sh - vault_api.sh (tries cache first, falls back to direct) - vault_auth.sh (tries cache first, falls back to direct) Benefits: - No more repeated AppRole logins - Sub-millisecond token retrieval vs 2-3 second Vault queries - All scripts automatically use latest cache - Fallback to direct Vault if cache missing/stale Pattern: source vault-env.sh TOKEN=*** # instant from cache Closes: vault cache migration
21 lines
689 B
Bash
Executable File
21 lines
689 B
Bash
Executable File
#!/bin/bash
|
|
# vault_auth.sh - Vault authentication (fallback to direct auth)
|
|
# For cached access, use vault-env.sh instead
|
|
|
|
VAULT_URL="https://beavault.beawit.net:8200"
|
|
|
|
# Try cache first
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
if [ -x "${SCRIPT_DIR}/vault-cache.sh" ]; then
|
|
TOKEN=$("${SCRIPT_DIR}/vault-cache.sh" get api/integration/grist token 2>/dev/null)
|
|
if [ -n "$TOKEN" ]; then
|
|
echo "$TOKEN"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Fallback to direct Vault auth
|
|
curl -sk -X POST \
|
|
-d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' \
|
|
"${VAULT_URL}/v1/auth/approle/login" | jq -r '.auth.client_token'
|