feat: OpenClaw external agent sync API at /api/openclaw/*
- API key auth via x-openclaw-key header (OPENCLAW_API_KEY env var)
- GET /api/openclaw/sync/status
- POST /api/openclaw/sync/autotask/incremental
- POST /api/openclaw/sync/autotask/full
- POST /api/openclaw/sync/autotask/entity { entities: [...] }
- POST /api/openclaw/sync/datto-rmm { syncType: full|incremental }
- POST /api/openclaw/sync/sentinelone
- POST /api/openclaw/sync/veeam { syncType: full|incremental }
- POST /api/openclaw/sync/zoom
- POST /api/openclaw/sync/engagement
- POST /api/openclaw/sync/qbo { syncType: full|incremental }
- POST /api/openclaw/sync/zabbix
- POST /api/openclaw/sync/itglue
All routes bypass Better Auth middleware, delegate to existing sync services
This commit is contained in:
parent
eea66de129
commit
5be7b22953
14 changed files with 450 additions and 0 deletions
22
lib/utils/openclaw-auth.ts
Normal file
22
lib/utils/openclaw-auth.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
/**
|
||||
* Validate the OpenClaw API key from the request header.
|
||||
* Returns a 401 NextResponse if invalid, or null if valid.
|
||||
*/
|
||||
export function validateOpenClawKey(request: NextRequest): NextResponse | null {
|
||||
const expectedKey = process.env.OPENCLAW_API_KEY;
|
||||
|
||||
if (!expectedKey) {
|
||||
console.error('[OpenClaw] OPENCLAW_API_KEY is not set');
|
||||
return NextResponse.json({ error: 'OpenClaw API not configured' }, { status: 500 });
|
||||
}
|
||||
|
||||
const providedKey = request.headers.get('x-openclaw-key');
|
||||
|
||||
if (!providedKey || providedKey !== expectedKey) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue