fix: ocp-connect tries anonymous access before requiring key

In zero-config auth mode, the server allows anonymous access even in
multi mode. The script now probes /v1/models first — if it succeeds,
no key is needed. Also updated README examples and version to 3.5.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 13:42:00 +10:00
co-authored by Claude Opus 4.6
parent b87992fa3b
commit 6d0e43ec37
2 changed files with 25 additions and 13 deletions
+11 -5
View File
@@ -1,6 +1,6 @@
# OCP — Open Claude Proxy # OCP — Open Claude Proxy
> **Status: Stable (v3.5.0)** — Feature-complete. Bug fixes only. > **Status: Stable (v3.5.1)** — Feature-complete. Bug fixes only.
> **Already paying for Claude Pro/Max? Use your subscription as an OpenAI-compatible API — $0 extra cost.** > **Already paying for Claude Pro/Max? Use your subscription as an OpenAI-compatible API — $0 extra cost.**
@@ -111,17 +111,22 @@ curl http://127.0.0.1:3456/v1/models
```bash ```bash
curl -fsSL https://raw.githubusercontent.com/dtzp555-max/ocp/main/ocp-connect -o ocp-connect curl -fsSL https://raw.githubusercontent.com/dtzp555-max/ocp/main/ocp-connect -o ocp-connect
chmod +x ocp-connect chmod +x ocp-connect
./ocp-connect <server-ip>
```
If the server requires a key, pass it with `--key`:
```bash
./ocp-connect <server-ip> --key <your-api-key> ./ocp-connect <server-ip> --key <your-api-key>
``` ```
Or as a one-liner (no file saved): Or as a one-liner (no file saved):
```bash ```bash
curl -fsSL https://raw.githubusercontent.com/dtzp555-max/ocp/main/ocp-connect | bash -s -- <server-ip> --key <your-api-key> curl -fsSL https://raw.githubusercontent.com/dtzp555-max/ocp/main/ocp-connect | bash -s -- <server-ip>
``` ```
Example: Example:
``` ```
$ ./ocp-connect 192.168.1.100 --key ocp_xDYzOB9ZKYzn $ ./ocp-connect 192.168.1.100
OCP Connect OCP Connect
───────────────────────────────────── ─────────────────────────────────────
@@ -130,14 +135,15 @@ OCP Connect
Checking connectivity... Checking connectivity...
✓ Connected ✓ Connected
Remote OCP v3.5.0 (auth: multi) Remote OCP v3.5.1 (auth: multi)
Server allows anonymous access — no key needed.
Testing API access... Testing API access...
✓ API accessible (3 models available) ✓ API accessible (3 models available)
Written to /home/user/.bashrc: Written to /home/user/.bashrc:
OPENAI_BASE_URL=http://192.168.1.100:3456/v1 OPENAI_BASE_URL=http://192.168.1.100:3456/v1
OPENAI_API_KEY=ocp_xDYz...
Running smoke test... Running smoke test...
✓ Smoke test passed: OK ✓ Smoke test passed: OK
+14 -8
View File
@@ -103,15 +103,21 @@ main() {
# Step 3: Determine if key is needed # Step 3: Determine if key is needed
if [[ "$auth_mode" != "none" && -z "$key" ]]; then if [[ "$auth_mode" != "none" && -z "$key" ]]; then
echo " Remote requires authentication." # Try anonymous access first (zero-config: server may allow it)
echo " Ask the OCP admin to run: ocp keys add <name>" if curl -sf --max-time 5 "$base_url/v1/models" >/dev/null 2>&1; then
printf " Enter API key (or press Enter to skip): " echo " Server allows anonymous access — no key needed."
read -rs key </dev/tty
echo
if [[ -z "$key" ]]; then
echo "" echo ""
echo " ✗ No key provided — cannot connect to an auth-required remote without a key." else
exit 1 echo " Remote requires authentication."
echo " Ask the OCP admin to run: ocp keys add <name>"
printf " Enter API key (or press Enter to skip): "
read -rs key </dev/tty
echo
if [[ -z "$key" ]]; then
echo ""
echo " ✗ No key provided — cannot connect to an auth-required remote without a key."
exit 1
fi
fi fi
fi fi