feat(center): API-key agent auth
UserApiKey (apiKeyHash->userId); CLI 'user apikey --email'; POST
/auth/agent/login {apiKey} -> normal user session (api-key-guard exempt).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
12
src/cli.ts
12
src/cli.ts
@@ -13,6 +13,7 @@ function getArg(flag: string): string | null {
|
||||
function printUsageAndExit(): never {
|
||||
console.error('Usage:');
|
||||
console.error(' node dist/cli.js user create --email <email> --password <password>');
|
||||
console.error(' node dist/cli.js user apikey --email <email> [--label <label>]');
|
||||
console.error(' node dist/cli.js node register --node-id <id> --name <name> --endpoint <url>');
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -34,6 +35,17 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (subject === 'user' && action === 'apikey') {
|
||||
const email = getArg('--email');
|
||||
const label = getArg('--label');
|
||||
if (!email) printUsageAndExit();
|
||||
|
||||
const auth = app.get(AuthService);
|
||||
const res = await auth.createUserApiKey(email, label ?? undefined);
|
||||
process.stdout.write(JSON.stringify({ ok: true, ...res }) + '\n');
|
||||
return;
|
||||
}
|
||||
|
||||
if (subject === 'node' && action === 'register') {
|
||||
const nodeId = getArg('--node-id');
|
||||
const name = getArg('--name');
|
||||
|
||||
Reference in New Issue
Block a user