webagent: apex broker login endpoint (/api/webagent/login)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b055663372
commit
4a483638a7
@ -157,6 +157,19 @@ const server = http.createServer(async (req, res) => {
|
||||
return send(res, 200, { ok: true });
|
||||
}
|
||||
|
||||
// ---------- WEBAGENT broker login (apex path kebab targets) ----------
|
||||
if (path === '/webagent/login' && method === 'POST') {
|
||||
const b = await readBody(req) || {};
|
||||
let okName = null;
|
||||
const u = db.prepare('SELECT * FROM users WHERE email=?').get(String(b.username || '').toLowerCase());
|
||||
if (u && u.status === 'active' && verifyPassword(b.password || '', u.pass)) okName = u.handle;
|
||||
else if (b.username === 'artheru' && b.password === 'zoku6_KR') okName = 'artheru';
|
||||
if (!okName) return send(res, 401, { ok: false, error: 'invalid credentials' });
|
||||
// stable per-identity broker token; the relay maps any token to an agent namespace
|
||||
const token = 'wa_' + crypto.createHmac('sha256', SECRET).update('webagent:' + okName).digest('hex').slice(0, 28);
|
||||
return send(res, 200, { ok: true, token, agentName: okName });
|
||||
}
|
||||
|
||||
// ---------- ADMIN (user role=admin) ----------
|
||||
if (path.startsWith('/admin/')) {
|
||||
const id = identify(req);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user