Files
smom-dbis-138/scripts/deployment/generate-portal-nginx-auth-snippet.sh
zaragoza444 064239be13
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m18s
CI/CD Pipeline / Security Scanning (push) Successful in 2m34s
CI/CD Pipeline / Lint and Format (push) Failing after 54s
CI/CD Pipeline / Terraform Validation (push) Failing after 27s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 28s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 39s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 31s
Validation / validate-genesis (push) Successful in 28s
Validation / validate-terraform (push) Failing after 31s
Validation / validate-kubernetes (push) Failing after 11s
Validation / validate-smart-contracts (push) Failing after 11s
Validation / validate-security (push) Failing after 1m27s
Validation / validate-documentation (push) Failing after 21s
Verify Deployment / Verify Deployment (push) Has been cancelled
feat: four super-admin keys and production customer API security
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 05:09:08 -07:00

48 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Write nginx auth snippet for portal (injects super-admin Bearer + internal header server-side).
set -euo pipefail
REPO_DIR="${OMNL_BANK_ROOT:-$HOME/smom-dbis-138}"
ENV_FILE="${OMNL_BANK_ENV:-$REPO_DIR/.env}"
CTID="${1:-5827}"
OUT="${2:-$REPO_DIR/deploy/nginx/omnl-portal-auth-${CTID}.conf.inc}"
CONFIG="$REPO_DIR/config/omnl-super-admins.v1.json"
if [[ ! -f "$ENV_FILE" ]]; then
echo "Missing $ENV_FILE" >&2
exit 1
fi
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
ENV_KEY="$(node -e "
const fs = require('fs');
const cfg = JSON.parse(fs.readFileSync('$CONFIG', 'utf8'));
const ct = Number('$CTID');
const admin = cfg.superAdmins.find(a => a.portalCtid === ct);
if (!admin) process.exit(2);
console.log(admin.envKey);
")"
API_KEY="${!ENV_KEY:-${OMNL_API_KEY:-}}"
INTERNAL="${OMNL_PORTAL_INTERNAL_SECRET:-}"
if [[ -z "$API_KEY" ]]; then
echo "No API key for CT $CTID ($ENV_KEY unset)" >&2
exit 1
fi
mkdir -p "$(dirname "$OUT")"
cat >"$OUT" <<EOF
# Auto-generated — do not commit. CT $CTID portal upstream auth.
proxy_set_header Authorization "Bearer ${API_KEY}";
proxy_set_header X-OMNL-Portal-Auth "${INTERNAL}";
EOF
chmod 600 "$OUT"
echo "Wrote $OUT"