feat(auth): add prime oauth broker service and provider config

This commit is contained in:
Prime Backup Bot
2026-03-11 15:49:27 +00:00
parent d05c098c02
commit 837f2550fc
5 changed files with 180 additions and 23 deletions
+34 -11
View File
@@ -1,15 +1,38 @@
# OAuth Bootstrap (Prime)
# Prime OAuth Bootstrap (OpenAI + Anthropic Claude Code)
Prime requires OAuth sessions for:
- OpenAI (planner brain)
- Anthropic (coder brain)
Prime OAuth broker runs locally on shard-host:
- Service: `prime-oauth.service`
- Health: `http://127.0.0.1:8787/health`
## Steps
1. Authenticate OpenAI OAuth in runtime (same pattern as OpenClaw).
2. Authenticate Anthropic OAuth in runtime.
3. Run `scripts/preflight-auth.sh`.
4. Confirm model routing with `config/model-router.yaml`.
## 1) Configure providers
Edit:
`/srv/prime-core/config/oauth/providers.json`
For each provider (`openai`, `anthropic`), set:
- `client_id`
- `client_secret`
- `auth_url`
- `token_url`
- `scopes`
## 2) Start OAuth flow
Request auth URL:
```bash
curl "http://127.0.0.1:8787/auth/anthropic/start?redirect_uri=<YOUR_REDIRECT_URI_URLENCODED>"
```
Open returned `auth_url` in browser, authorize, then callback hits:
`/auth/anthropic/callback?code=...&state=...`
Do same for OpenAI provider.
## 3) Validate token presence
```bash
source /srv/prime-core/scripts/prime-env.sh
prime status
```
`oauth_providers` should include `openai` and `anthropic`.
## Notes
- Do not set `OPENAI_API_KEY` / `ANTHROPIC_API_KEY`.
- If OAuth for Anthropic is not available in runtime, Prime must remain in queue+alert mode for coding tasks.
- Prime is OAuth-only by policy.
- No API keys are used for model runtime access.
- Token material is encrypted at rest in `/srv/prime-core/state/tokens.enc`.