Migrate all scripts to use vault cache
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
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
#!/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-agent.sh - Check agent tables in NocoDB
|
||||
# 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=$(vaul…ken)
|
||||
|
||||
echo "Token: ${NOCODB_TOKEN:0:20}..."
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Token: ${NOCODB_TOKEN:***"
|
||||
|
||||
# Check tables in Agent base
|
||||
echo "=== Tables in Agent base ==="
|
||||
|
||||
Regular → Executable
+11
-10
@@ -1,23 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Fixing SingleSelect columns in NocoDB..."
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
|
||||
echo "Got NocoDB token"
|
||||
|
||||
# Get column IDs
|
||||
echo "Fetching column IDs..."
|
||||
COLS=$(curl -s "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys" -H "xc-token: $NOCODB_TOKEN")
|
||||
TYPE_ID=$(echo "$COLS" | jq -r '.columns[] | select(.title=="type") | .id')
|
||||
SEVERITY_ID=$(echo "$COLS" | jq -r '.columns[] | select(.title=="severity") | .id')
|
||||
STATUS_ID=$(echo "$COLS" | jq -r '.columns[] | select(.title=="status") | .id')
|
||||
|
||||
echo "type column ID: $TYPE_ID"
|
||||
echo "severity column ID: $SEVERITY_ID"
|
||||
echo "status column ID: $STATUS_ID"
|
||||
|
||||
# Fix type column
|
||||
echo ""
|
||||
echo "Fixing type column..."
|
||||
@@ -25,7 +29,6 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/$TYPE_ID" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"dtxp": "'"'"'correction'"'"','"'"'preference'"'"','"'"'episode'"'"','"'"'decision'"'"','"'"'validation'"'"'"}' | jq -r '.columns[] | select(.title=="type") | .dtxp'
|
||||
|
||||
# Fix severity column
|
||||
echo ""
|
||||
echo "Fixing severity column..."
|
||||
@@ -33,7 +36,6 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/$SEVERITY_ID" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"dtxp": "'"'"'error'"'"','"'"'warning'"'"','"'"'auto-correct'"'"'"}' | jq -r '.columns[] | select(.title=="severity") | .dtxp'
|
||||
|
||||
# Fix status column
|
||||
echo ""
|
||||
echo "Fixing status column..."
|
||||
@@ -41,6 +43,5 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/$STATUS_ID" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"dtxp": "'"'"'active'"'"','"'"'reversed'"'"','"'"'deprecated'"'"'"}' | jq -r '.columns[] | select(.title=="status") | .dtxp'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+11
-7
@@ -1,11 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get tokens
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
|
||||
echo "Updating severity column..."
|
||||
|
||||
# Update severity column (ID: cv1al80v3ejvij0)
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cv1al80v3ejvij0" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -20,10 +27,8 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cv1al80v3ejvij0"
|
||||
]
|
||||
}
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Updating status column..."
|
||||
|
||||
# Update status column (ID: cxbxnyh03nkvd0a)
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -38,6 +43,5 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a"
|
||||
]
|
||||
}
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+10
-4
@@ -1,14 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating status column..."
|
||||
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"dtxp":"active,reversed,deprecated","meta":{"options":[{"title":"active","color":"#00FF00"},{"title":"reversed","color":"#FFA500"},{"title":"deprecated","color":"#808080"}]}}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+11
-5
@@ -1,11 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get tokens
|
||||
VAULT_TOKEN=*** -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 | jq -r '.auth.client_token')
|
||||
NOCODB_TOKEN=*** -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
|
||||
|
||||
echo "Updating status column (ID: cxbxnyh03nkvd0a)..."
|
||||
|
||||
# Update status column with proper options
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -20,6 +27,5 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a"
|
||||
]
|
||||
}
|
||||
}' | jq -c '{id: .id, title: .title, meta: .meta}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+10
-4
@@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Fixing type column options (ID: ctkqqemeblx80cc)..."
|
||||
|
||||
# Update type column with proper dtxp format
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -12,6 +19,5 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc"
|
||||
-d '{
|
||||
"dtxp": "correction,preference,episode,decision,validation"
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+10
-6
@@ -1,17 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Getting current column config..."
|
||||
|
||||
# Get current column
|
||||
curl -s "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
|
||||
-H "xc-token: $NOCODB_TOKEN" | jq '.colOptions'
|
||||
|
||||
echo ""
|
||||
echo "Updating colOptions for type column..."
|
||||
|
||||
# Update colOptions via the options endpoint
|
||||
curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/colOptions/options" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -25,6 +30,5 @@ curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/co
|
||||
{"title": "validation", "color": "#FF00FF"}
|
||||
]
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+10
-4
@@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Patching type column with dtxp..."
|
||||
|
||||
# Patch the column with proper enum values in dtxp
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -12,6 +19,5 @@ curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc"
|
||||
-d '{
|
||||
"dtxp": "'"'"'correction'"'"','"'"'preference'"'"','"'"'episode'"'"','"'"'decision'"'"','"'"'validation'"'"'"
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
Regular → Executable
+11
-15
@@ -1,18 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Get Grist API token from Vault
|
||||
# Usage: source get_grist_token.sh (requires VAULT_TOKEN from vault_auth.sh)
|
||||
# get_grist_token.sh - Get Grist token from vault cache
|
||||
|
||||
if [ -z "$VAULT_TOKEN" ]; then
|
||||
echo "Error: Run vault_auth.sh first"
|
||||
return 1
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/vault-env.sh"
|
||||
|
||||
TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -n "$TOKEN" ]; then
|
||||
echo "Grist token: ${TOKEN:***"
|
||||
else
|
||||
echo "Error: Could not retrieve Grist token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export GRIST_TOKEN=*** -sk -H "X-Vault-Token: $VAULT_TOKEN" \
|
||||
"https://beavault.beawit.net:8200/v1/kv/data/api/integration/grist" | jq -r '.data.data.token')
|
||||
|
||||
if [ -z "$GRIST_TOKEN" ] || [ "$GRIST_TOKEN" = "null" ]; then
|
||||
echo "Failed to get Grist token from Vault"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Grist token retrieved: ${GRIST_TOKEN:***
|
||||
+23
-92
@@ -1,102 +1,33 @@
|
||||
#!/bin/bash
|
||||
# Self-healing Grist API wrapper
|
||||
# Tries cached token first, auto-refreshes from Vault on failure
|
||||
# grist_api.sh - Grist API wrapper using vault cache
|
||||
# Usage: source this file or call its functions
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/vault-env.sh"
|
||||
|
||||
TOKEN_DIR="/home/jcbeasley/.openclaw/workspace/.tokens"
|
||||
VAULT_URL="https://beavault.beawit.net:8200"
|
||||
GRIST_URL="https://grist.beawit.net"
|
||||
GRIST_TOKEN_FILE="$TOKEN_DIR/grist_token"
|
||||
GRIST_TOKEN=$(vaul…ken)
|
||||
|
||||
METHOD="$1"
|
||||
API_PATH="$2"
|
||||
PAYLOAD_FILE="$3"
|
||||
|
||||
if [ -z "$METHOD" ] || [ -z "$API_PATH" ]; then
|
||||
echo "Usage: bash grist_api.sh <METHOD> <API_PATH> [payload_file]"
|
||||
exit 1
|
||||
if [ -z "$GRIST_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve Grist token from vault cache"
|
||||
return 1 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
# Function to refresh tokens from Vault
|
||||
refresh_tokens() {
|
||||
mkdir -p "$TOKEN_DIR"
|
||||
# Function to make Grist API calls
|
||||
grist_api() {
|
||||
local method="${1:-GET}"
|
||||
local endpoint="$2"
|
||||
local payload="${3:-}"
|
||||
|
||||
# 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" \
|
||||
> "$TOKEN_DIR/vault_auth.json"
|
||||
local headers=(-H "Authorization: Bearer ${GRIST_TOKEN}" -H "Content-Type: application/json")
|
||||
|
||||
python3 -c "
|
||||
import json
|
||||
with open('$TOKEN_DIR/vault_auth.json') as f:
|
||||
data = json.load(f)
|
||||
with open('$TOKEN_DIR/vault_token', 'w') as out:
|
||||
out.write(data['auth']['client_token'])
|
||||
"
|
||||
|
||||
# Get Grist token
|
||||
curl -sk -H "X-Vault-Token: $(cat $TOKEN_DIR/vault_token)" \
|
||||
"$VAULT_URL/v1/kv/data/api/integration/grist" \
|
||||
> "$TOKEN_DIR/grist_from_vault.json"
|
||||
|
||||
python3 -c "
|
||||
import json
|
||||
with open('$TOKEN_DIR/grist_from_vault.json') as f:
|
||||
data = json.load(f)
|
||||
with open('$TOKEN_DIR/grist_token', 'w') as out:
|
||||
out.write(data['data']['data']['token'])
|
||||
"
|
||||
|
||||
rm -f "$TOKEN_DIR/vault_auth.json" "$TOKEN_DIR/grist_from_vault.json"
|
||||
if [ "$method" = "GET" ]; then
|
||||
curl -sk "${headers[@]}" "${GRIST_URL}${endpoint}"
|
||||
else
|
||||
curl -sk -X "$method" "${headers[@]}" -d "$payload" "${GRIST_URL}${endpoint}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to make Grist API call
|
||||
api_call() {
|
||||
local http_code
|
||||
|
||||
if [ "$METHOD" = "GET" ]; then
|
||||
http_code=$(curl -sk -w "%{http_code}" -o "$TOKEN_DIR/last_response.json" \
|
||||
-H "Authorization: Bearer $(cat $GRIST_TOKEN_FILE)" \
|
||||
-H "Content-Type: application/json" \
|
||||
"$GRIST_URL$API_PATH")
|
||||
elif [ "$METHOD" = "PATCH" ] && [ -n "$PAYLOAD_FILE" ]; then
|
||||
http_code=$(curl -sk -w "%{http_code}" -o "$TOKEN_DIR/last_response.json" \
|
||||
-H "Authorization: Bearer $(cat $GRIST_TOKEN_FILE)" \
|
||||
-H "Content-Type: application/json" \
|
||||
-X PATCH \
|
||||
-d "@$PAYLOAD_FILE" \
|
||||
"$GRIST_URL$API_PATH")
|
||||
else
|
||||
echo "Error: Unsupported method or missing payload"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$http_code"
|
||||
}
|
||||
|
||||
# Main logic: try cached token, refresh on failure, retry
|
||||
if [ ! -f "$GRIST_TOKEN_FILE" ]; then
|
||||
refresh_tokens
|
||||
fi
|
||||
|
||||
HTTP_CODE=$(api_call)
|
||||
|
||||
# If unauthorized (401) or forbidden (403), refresh and retry
|
||||
if [ "$HTTP_CODE" = "401" ] || [ "$HTTP_CODE" = "403" ]; then
|
||||
refresh_tokens
|
||||
HTTP_CODE=$(api_call)
|
||||
fi
|
||||
|
||||
# Output response
|
||||
if [ -f "$TOKEN_DIR/last_response.json" ]; then
|
||||
cat "$TOKEN_DIR/last_response.json"
|
||||
rm -f "$TOKEN_DIR/last_response.json"
|
||||
fi
|
||||
|
||||
# Return appropriate exit code
|
||||
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "204" ]; then
|
||||
exit 0
|
||||
else
|
||||
echo "Error: HTTP $HTTP_CODE" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Export
|
||||
export -f grist_api
|
||||
export GRIST_URL GRIST_TOKEN
|
||||
|
||||
+12
-41
@@ -1,44 +1,15 @@
|
||||
#!/bin/bash
|
||||
# Refresh Vault and Grist tokens
|
||||
# Tokens are written to files only, never exposed in stdout
|
||||
# refresh_tokens.sh - Refresh all vault cache tokens
|
||||
# This script forces a re-sync of the vault cache
|
||||
|
||||
TOKEN_DIR="/home/jcbeasley/.openclaw/workspace/.tokens"
|
||||
VAULT_URL="https://beavault.beawit.net:8200"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
mkdir -p "$TOKEN_DIR"
|
||||
|
||||
# Step 1: Authenticate to Vault
|
||||
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" \
|
||||
> "$TOKEN_DIR/vault_auth_response.json"
|
||||
|
||||
# Step 2: Extract Vault token
|
||||
python3 -c "
|
||||
import json
|
||||
with open('$TOKEN_DIR/vault_auth_response.json') as f:
|
||||
data = json.load(f)
|
||||
token = data['auth']['client_token']
|
||||
with open('$TOKEN_DIR/vault_token', 'w') as out:
|
||||
out.write(token)
|
||||
"
|
||||
|
||||
# Step 3: Get Grist token from Vault (direct file reference, no variable assignment)
|
||||
curl -sk -H "X-Vault-Token: $(cat $TOKEN_DIR/vault_token)" \
|
||||
"$VAULT_URL/v1/kv/data/api/integration/grist" \
|
||||
> "$TOKEN_DIR/grist_vault_response.json"
|
||||
|
||||
# Step 4: Extract Grist token
|
||||
python3 -c "
|
||||
import json
|
||||
with open('$TOKEN_DIR/grist_vault_response.json') as f:
|
||||
data = json.load(f)
|
||||
token = data['data']['data']['token']
|
||||
with open('$TOKEN_DIR/grist_token', 'w') as out:
|
||||
out.write(token)
|
||||
"
|
||||
|
||||
# Step 5: Clean up
|
||||
rm -f "$TOKEN_DIR/vault_auth_response.json" "$TOKEN_DIR/grist_vault_response.json"
|
||||
|
||||
echo "Tokens refreshed successfully"
|
||||
if [ -x "${SCRIPT_DIR}/vault-cache.sh" ]; then
|
||||
echo "Refreshing vault cache..."
|
||||
"${SCRIPT_DIR}/vault-cache.sh" invalidate all
|
||||
"${SCRIPT_DIR}/vault-cache.sh" sync
|
||||
echo "Cache refreshed"
|
||||
else
|
||||
echo "Error: vault-cache.sh not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,29 +1,15 @@
|
||||
#!/bin/bash
|
||||
# Store Grist token in Vault
|
||||
# Usage: GRIST_TOKEN="your-token-here" bash store_grist_token.sh
|
||||
# store_grist_token.sh - Store Grist token (uses vault cache now)
|
||||
|
||||
if [ -z "$GRIST_TOKEN" ]; then
|
||||
echo "Error: Set GRIST_TOKEN environment variable first"
|
||||
echo "Example: GRIST_TOKEN='your-token' bash store_grist_token.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/vault-env.sh"
|
||||
|
||||
TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -n "$TOKEN" ]; then
|
||||
echo "Grist token available from cache"
|
||||
echo "Token: ${TOKEN:***"
|
||||
else
|
||||
echo "Error: Could not retrieve Grist token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VAULT_TOKEN=$(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" | jq -r '.auth.client_token')
|
||||
|
||||
echo "Storing Grist token in Vault..."
|
||||
|
||||
curl -sk -X POST \
|
||||
-H "X-Vault-Token: $VAULT_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"data\":{\"token\":\"$GRIST_TOKEN\"}}" \
|
||||
"https://beavault.beawit.net:8200/v1/kv/data/api/integration/grist"
|
||||
|
||||
echo ""
|
||||
echo "Verifying..."
|
||||
curl -sk -H "X-Vault-Token: $VAULT_TOKEN" \
|
||||
"https://beavault.beawit.net:8200/v1/kv/data/api/integration/grist" | jq -r '.data.data.token'
|
||||
|
||||
echo ""
|
||||
echo "Done. Token stored at kv/data/api/integration/grist"
|
||||
@@ -1,35 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Update Survey_Date column in Grist using Vault for API token
|
||||
# update_survey_dates.sh - Update survey dates in NocoDB
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
GRIST_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ] || [ -z "$GRIST_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve tokens from vault cache"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update Survey_Date column in Grist using Vault for API token
|
||||
# Step 1: Get Vault token
|
||||
VAULT_RESPONSE=$(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")
|
||||
|
||||
VAULT_TOKEN=$(echo "$VAULT_RESPONSE" | jq -r '.auth.client_token')
|
||||
|
||||
if [ -z "$VAULT_TOKEN" ] || [ "$VAULT_TOKEN" = "null" ]; then
|
||||
echo "Failed to get Vault token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 2: Get Grist token from Vault
|
||||
GRIST_RESPONSE=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" \
|
||||
"https://beavault.beawit.net:8200/v1/kv/data/api/integration/grist")
|
||||
|
||||
GRIST_TOKEN=$(echo "$GRIST_RESPONSE" | jq -r '.data.data.token')
|
||||
|
||||
if [ -z "$GRIST_TOKEN" ] || [ "$GRIST_TOKEN" = "null" ]; then
|
||||
echo "Failed to get Grist token from Vault"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Vault auth: OK"
|
||||
echo "Grist token retrieved: ${GRIST_TOKEN:0:10}..."
|
||||
|
||||
# Step 3: Update Survey_Date in Grist
|
||||
API_URL="https://grist.beawit.net/api/docs/wmBGUbgBveCdeY8fZ6T6eL/tables/Intune/records"
|
||||
|
||||
curl -sk "$API_URL" \
|
||||
-H "Authorization: Bearer $GRIST_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -93,6 +95,5 @@ curl -sk "$API_URL" \
|
||||
{"id":61,"fields":{"Survey_Date":"2026-10-03"}},
|
||||
{"id":63,"fields":{"Survey_Date":"2026-10-03"}}
|
||||
]}'
|
||||
|
||||
echo ""
|
||||
echo "Survey dates update complete"
|
||||
Regular → Executable
+10
-3
@@ -1,9 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Getting colOptions..."
|
||||
|
||||
curl -s "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc/colOptions" \
|
||||
-H "xc-token: $NOCODB_TOKEN" | jq '.'
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get vault token
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_token')
|
||||
|
||||
# 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"]')
|
||||
|
||||
echo "NocoDB Token: ${NOCODB_TOKEN:0:20}..."
|
||||
|
||||
# Get column ID for 'type'
|
||||
echo "=== Getting type column ID ==="
|
||||
curl -s "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys" \
|
||||
|
||||
Regular → Executable
+10
-6
@@ -1,17 +1,22 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
VAULT_TOKEN=$(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 | jq -r '.auth.client_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"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Deleting type column..."
|
||||
|
||||
# Delete the type column
|
||||
curl -s -X DELETE "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
|
||||
-H "xc-token: $NOCODB_TOKEN"
|
||||
|
||||
echo ""
|
||||
echo "Recreating type column with options..."
|
||||
|
||||
# Create new SingleSelect column with options
|
||||
curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys/columns" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
@@ -22,6 +27,5 @@ curl -s -X POST "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys/col
|
||||
"uidt": "SingleSelect",
|
||||
"dtxp": "correction,preference,episode,decision,validation"
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "Done!"
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vaul…ken)
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get vault token
|
||||
VAULT_TOKEN=$(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" | jq -r '.auth.client_token')
|
||||
|
||||
# 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"]')
|
||||
|
||||
echo "Token: ${NOCODB_TOKEN:0:20}..."
|
||||
|
||||
# First get the table to find column IDs
|
||||
echo "=== Getting table metadata ==="
|
||||
curl -s "http://192.168.25.5:8080/api/v2/meta/tables/mx149yctebfwvys" \
|
||||
|
||||
+28
-13
@@ -1,13 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Generic API wrapper using Vault for dynamic token retrieval
|
||||
# Supports multiple auth header types
|
||||
# vault_api.sh - Generic API wrapper using Vault for dynamic token retrieval
|
||||
#
|
||||
# This script now tries the local vault cache FIRST, and only falls back to
|
||||
# direct Vault API calls if the cache is missing/stale.
|
||||
#
|
||||
# Usage: bash vault_api.sh <METHOD> <BASE_URL> <API_PATH> <VAULT_KEY> [header_type] [payload_file]
|
||||
# Examples:
|
||||
# bash vault_api.sh GET "https://grist.beawit.net" "/api/..." "api/integration/grist" "Bearer"
|
||||
# bash vault_api.sh GET "http://192.168.25.5:8080" "/api/..." "api/integration/nocodb" "xc-token"
|
||||
|
||||
TOKEN_DIR="/home/jcbeasley/.openclaw/workspace/.tokens"
|
||||
VAULT_URL="https://beavault.beawit.net:8200"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
METHOD="$1"
|
||||
BASE_URL="$2"
|
||||
@@ -18,14 +19,16 @@ PAYLOAD_FILE="$6"
|
||||
|
||||
if [ -z "$METHOD" ] || [ -z "$BASE_URL" ] || [ -z "$API_PATH" ] || [ -z "$VAULT_KEY" ]; then
|
||||
echo "Usage: bash vault_api.sh <METHOD> <BASE_URL> <API_PATH> <VAULT_KEY> [header_type] [payload_file]"
|
||||
echo "Header types: Bearer (default), xc-token, api-key, X-Api-Key, X-Vault-Token"
|
||||
echo "Example: bash vault_api.sh GET 'https://grist.beawit.net' '/api/...' 'api/integration/grist' 'Bearer'"
|
||||
echo ""
|
||||
echo "TIP: Use vault-cache.sh for faster repeated access:"
|
||||
echo " ./vault-cache.sh sync"
|
||||
echo " ./vault-cache.sh get <path> <field>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$TOKEN_DIR"
|
||||
|
||||
# Function to get Vault token
|
||||
# Function to get Vault token (with caching)
|
||||
cache_vault_token() {
|
||||
local cached_token="$TOKEN_DIR/vault_session_token"
|
||||
|
||||
@@ -53,12 +56,23 @@ with open('$TOKEN_DIR/vault_auth.json') as f:
|
||||
cat "$cached_token"
|
||||
}
|
||||
|
||||
# Function to get service token
|
||||
# Function to get service token (try vault cache first)
|
||||
cache_service_token() {
|
||||
local vault_token="$1"
|
||||
local vault_key="$2"
|
||||
local cache_file="$TOKEN_DIR/service_$(echo "$vault_key" | tr '/' '_').token"
|
||||
|
||||
# Try local vault cache FIRST
|
||||
if [ -x "${SCRIPT_DIR}/vault-cache.sh" ]; then
|
||||
local cached_token
|
||||
cached_token=***"${SCRIPT_DIR}/vault-cache.sh" get "$vault_key" token 2>/dev/null)
|
||||
if [ -n "$cached_token" ]; then
|
||||
echo "$cached_token"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fall back to file-based cache
|
||||
if [ -f "$cache_file" ]; then
|
||||
local age
|
||||
age=$(($(date +%s) - $(stat -c %Y "$cache_file")))
|
||||
@@ -68,6 +82,7 @@ cache_service_token() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fall back to direct Vault API
|
||||
curl -sk -H "X-Vault-Token: $vault_token" \
|
||||
"$VAULT_URL/v1/kv/data/$vault_key" > "$TOKEN_DIR/service_resp.json"
|
||||
|
||||
@@ -86,7 +101,7 @@ with open('$TOKEN_DIR/service_resp.json') as f:
|
||||
# Build auth header based on type
|
||||
build_auth_header() {
|
||||
local header_type="$1"
|
||||
local token="$2"
|
||||
local token="***"
|
||||
|
||||
case "$header_type" in
|
||||
"xc-token")
|
||||
@@ -96,7 +111,7 @@ build_auth_header() {
|
||||
echo "API-Key: $token"
|
||||
;;
|
||||
"X-Api-Key"|"x-api-key")
|
||||
echo "X-Api-Key: $token"
|
||||
echo "X-Api-Key: ***"
|
||||
;;
|
||||
"X-Vault-Token"|"vault")
|
||||
echo "X-Vault-Token: $token"
|
||||
@@ -108,8 +123,8 @@ build_auth_header() {
|
||||
}
|
||||
|
||||
# Main logic
|
||||
VAULT_TOKEN=$(cache_vault_token)
|
||||
SERVICE_TOKEN=$(cache_service_token "$VAULT_TOKEN" "$VAULT_KEY")
|
||||
VAULT_TOKEN=$(cach…ken)
|
||||
SERVICE_TOKEN=$(cach…oken "$VAULT_TOKEN" "$VAULT_KEY")
|
||||
AUTH_HEADER=$(build_auth_header "$HEADER_TYPE" "$SERVICE_TOKEN")
|
||||
|
||||
URL="${BASE_URL}${API_PATH}"
|
||||
|
||||
Regular → Executable
+15
-9
@@ -1,14 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Reusable Vault authentication script
|
||||
# Usage: source vault_auth.sh
|
||||
# vault_auth.sh - Vault authentication (fallback to direct auth)
|
||||
# For cached access, use vault-env.sh instead
|
||||
|
||||
export VAULT_TOKEN=*** -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" | jq -r '.auth.client_token')
|
||||
VAULT_URL="https://beavault.beawit.net:8200"
|
||||
|
||||
if [ -z "$VAULT_TOKEN" ] || [ "$VAULT_TOKEN" = "null" ]; then
|
||||
echo "Vault authentication failed"
|
||||
return 1
|
||||
# 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
|
||||
|
||||
echo "Vault authenticated successfully"
|
||||
# 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'
|
||||
|
||||
Reference in New Issue
Block a user