### Prepare deployment directory and download client policy Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Creates the config and data directories, downloads the example client policy, and generates a development token. The example policy is a starting point only: replace its development token, narrow its host and port allowlist, and keep the resulting file private. ```sh mkdir -p config data chmod 700 config data VERSION=0.1.0 RELEASE_TAG="v${VERSION}" IMAGE="ghcr.io/abagile/tokyo3-veilgate:${VERSION}" curl -fsSL \ "https://raw.githubusercontent.com/abagile/tokyo3-veilgate/${RELEASE_TAG}/config/clients.example.json" \ -o config/clients.json # Generate a token of at least 24 characters and put it in clients.json. openssl rand -base64 32 ``` -------------------------------- ### Copy example configs and generate random token Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Copies example policy files into place and generates a random token. Replace the token with a cryptographically random value of at least 24 characters. ```sh cp config/clients.example.json config/clients.json cp config/secrets.example.json config/secrets.json cp config/oauth.example.json config/oauth.json openssl rand -base64 32 ``` -------------------------------- ### Create .env and start Compose services Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Creates a .env file with image tag, UID/GID, and console credentials, then pulls and starts the Compose services. The .env file is chmod 600 for security. If config/secrets.json exists, uncomment VEILGATED_DEV_API_KEY and set its value. ```sh cat > .env <; override IMAGE_NAME, IMAGE_TAG, and TARGETARCH as needed. ```sh make docker-build ``` -------------------------------- ### OAuth broker configuration JSON Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Defines an OAuth broker with a name, allowed clients, issuer host, token path, API hosts, and token field names. Set VEILGATED_OAUTH_FILE or place a non-empty file at /etc/veilgate/oauth.json to enable. Missing or empty files are ignored. Optionally set access_placeholder_prefix for recognizable access-token shapes. ```json { "brokers": [{ "name": "example", "clients": ["agent-dev"], "issuer_host": "login.example.com", "token_path": "/oauth/token", "api_hosts": ["api.example.com"], "access_token_field": "access_token", "refresh_token_field": "refresh_token" }] } ``` -------------------------------- ### Download optional secrets and OAuth configuration Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Downloads the optional static secret and OAuth policy configuration files. The static secret and OAuth policies are optional; download and configure them only when they are needed. ```sh RELEASE_TAG="${RELEASE_TAG:-v0.1.0}" # Static substitution (the example uses VEILGATED_DEV_API_KEY): curl -fsSL \ "https://raw.githubusercontent.com/abagile/tokyo3-veilgate/${RELEASE_TAG}/config/secrets.example.json" \ -o config/secrets.json # OAuth brokering: curl -fsSL \ "https://raw.githubusercontent.com/abagile/tokyo3-veilgate/${RELEASE_TAG}/config/oauth.example.json" \ -o config/oauth.json ``` -------------------------------- ### Client policy with allowed_hosts and opaque_hosts Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Defines a client allowing exact hosts or leftmost-label wildcards. allowed_ports defaults to [443] when omitted. Direct IP targets are rejected. ```json { "clients": [ { "name": "agent-dev", "token": "a-long-random-lifecycle-scoped-token", "allowed_hosts": ["api.openai.com", "*.npmjs.org"], "opaque_hosts": ["registry.npmjs.org"], "allowed_ports": [443] } ] } ``` -------------------------------- ### Client policy with observe_all_public_hosts Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Allows any valid public hostname for a short-lived broad-egress client. Does not permit direct IP targets, private/special-use addresses, or ports outside allowed_ports. If allowed_hosts is also present, it is redundant. ```json { "clients": [{ "name": "inspection-agent", "token": "a-separate-short-lived-random-token", "observe_all_public_hosts": true, "allowed_ports": [443] }] } ``` -------------------------------- ### Capture-display test requests with curl and wscat Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Use these commands to test capture-display against public endpoints (httpbin.org, postman-echo.com, echo.websocket.org) on port 443. They exercise JSON, HTML, streaming, and WebSocket echo. Do not send real credentials or sensitive prompts to these endpoints. ```sh # JSON, HTML, JSONL-style streaming records, and an echoed JSON request. curl --proxy https://veilgated-proxy:8080 --proxy-cacert config/intercept-ca.crt \ --proxy-user "agent-dev:$TOKEN" --cacert config/intercept-ca.crt https://httpbin.org/json curl --proxy https://veilgated-proxy:8080 --proxy-cacert config/intercept-ca.crt \ --proxy-user "agent-dev:$TOKEN" --cacert config/intercept-ca.crt https://httpbin.org/html curl --proxy https://veilgated-proxy:8080 --proxy-cacert config/intercept-ca.crt \ --proxy-user "agent-dev:$TOKEN" --cacert config/intercept-ca.crt https://httpbin.org/stream/3 curl --proxy https://veilgated-proxy:8080 --proxy-cacert config/intercept-ca.crt \ --proxy-user "agent-dev:$TOKEN" --cacert config/intercept-ca.crt \ -H 'Content-Type: application/json' --data '{"agent":"veilgate","step":1}' \ https://postman-echo.com/post # Uncompressed WSS text-frame echo. npx --yes wscat --connect wss://echo.websocket.org \ --proxy "https://agent-dev:$TOKEN@veilgated-proxy:8080" \ --ca config/intercept-ca.crt --execute '{"agent":"veilgate","step":1}' \ --wait 2 ``` -------------------------------- ### Connect sandbox container to network Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Connects an existing sandbox container to the veilgate-sandbox network, using the VEILGATE_SANDBOX_NETWORK environment variable if set. This allows containers from another Compose project to join the sandbox network. ```sh docker network connect "${VEILGATE_SANDBOX_NETWORK:-veilgate-sandbox}" ``` -------------------------------- ### Generate proxy interception material and console certificate Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Generates the proxy interception CA and certificate with the image itself, and the console certificate with mkcert. For production, provision equivalent certificates and keys from the organization's certificate or secret-management system instead. ```sh IMAGE="${IMAGE:-ghcr.io/abagile/tokyo3-veilgate:0.1.0}" docker pull "$IMAGE" docker run --rm --user "$(id -u):$(id -g)" \ -v "$PWD/config:/etc/veilgate" \ "$IMAGE" ca init \ --cert /etc/veilgate/intercept-ca.crt \ --key /etc/veilgate/intercept-ca.key docker run --rm --user "$(id -u):$(id -g)" \ -v "$PWD/config:/etc/veilgate" \ "$IMAGE" ca sign \ --ca-cert /etc/veilgate/intercept-ca.crt \ --ca-key /etc/veilgate/intercept-ca.key \ --cert /etc/veilgate/proxy.crt \ --key /etc/veilgate/proxy.key \ --san 'DNS:veilgated-proxy,DNS:localhost,IP:127.0.0.1,IP:::1' mkcert -install mkcert -cert-file config/console.crt -key-file config/console.key \ localhost 127.0.0.1 ::1 veilgated.localhost chmod 600 config/*key ``` -------------------------------- ### Secret definition with environment variable and placeholder Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Defines a secret using a host-only environment variable (VEILGATED_ prefix) and a placeholder (VEILGATED_SECRET_ prefix). Placeholders are replaced only after all checks pass; resolved values must be 8–16384 bytes. ```json { "secrets": [{ "name": "openai_api_key", "value_env": "VEILGATED_OPENAI_KEY", "placeholder": "VEILGATED_SECRET_high_entropy_random_value", "clients": ["agent-dev"], "allowed_hosts": ["api.openai.com"] }] } ``` -------------------------------- ### Test development secret substitution with curl Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Sends a request through the Veilgated proxy to test secret substitution. Uses the development placeholder VEILGATED_SECRET_5f73a1c9e2b84d60a7f3 in the Authorization header. The proxy URL must use https://; plaintext connections are rejected. ```sh curl --proxy https://veilgated-proxy:8080 \ --proxy-cacert config/intercept-ca.crt \ --proxy-user 'agent-dev:YOUR_PROXY_TOKEN' \ --cacert config/intercept-ca.crt \ -H 'Authorization: Bearer VEILGATED_SECRET_5f73a1c9e2b84d60a7f3' \ https://api.openai.com/v1/models ``` -------------------------------- ### Stop deployment without deleting state Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Stops the Compose services while preserving the data directory and other state. Use this command when you want to halt the deployment without removing persistent data. ```sh docker compose down ``` -------------------------------- ### curl with Bearer token proxy authentication Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Use this command to make an HTTPS request through the Veilgate proxy using a Bearer token in the Proxy-Authorization header. It specifies the proxy CA certificate and the target CA certificate. Replace YOUR_TOKEN with the actual token. ```sh curl --proxy https://veilgated-proxy:8080 \ --proxy-cacert config/intercept-ca.crt \ --proxy-header 'Proxy-Authorization: Bearer YOUR_TOKEN' \ --cacert config/intercept-ca.crt \ https://api.openai.com/ ``` -------------------------------- ### Stop Docker Compose test deployment Source: https://github.com/abagile/tokyo3-veilgate/blob/main/README.md Stops the running Compose test deployment. ```sh make docker-down ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.