- MCP
- show on this site's /mcp
- CLI
- abso show 259 --json
- JSON
- /christopher/abso-core/versions/259?format=json
Box sign-ins asked of a person (abso 684, client; Security's yes with changes on ask 2097). In an agent's folder on the same server, abso login also asks a person in that project to approve it, through POST /login/ask with the folder's agent key and this client's own device code, then an ordinary abso ask (to person:<id>) with the request link, linked with /login/ask/link. It says who it asked and until when, keeps the code link as a fallback, says who turned it down on a deny, and withdraws its ask when nobody answers in time. --no-ask shows the code only. Tests: client/test/box.test.ts, three new (abso 684).
of shared·approvals-page··Not checked
Version 258 · Files at version 259
3 files, 213 lines added, 12 removed.
--- a/client/src/box.ts
+++ b/client/src/box.ts
@@ -222,7 +222,7 @@
223223
224224/** This machine's name, as the server takes a box's name: 1-64 letters, digits, '.', '_' or '-'. */
225−function boxName(): string {
@@ -254,8 +254,29 @@
255255 /** Opens the approve page in a browser, answering whether it tried. None where it shouldn't (--no-browser, SSH, CI). */
258+ * abso 684: in a joined folder, asks a person in its project to approve this sign-in, through an abso ask, so nobody
261+ readonly ask?: (codes: { readonly device: string; readonly user: string }) => Promise<LoginAsked | null>;
258263
277+
278+const CENTRAL = new Intl.DateTimeFormat("en-US", { timeZone: "America/Chicago", hour: "numeric", minute: "2-digit" });
279+
@@ -278,16 +299,29 @@
280301 // The page opens with the code in it, so nobody copies a link by hand. The link and code are printed all the same.
281− if (io.open?.(link)) io.say("Opening the approve page in your browser.");
282− io.say(`To sign this box in, open ${link} and approve the code ${code}.`);
283− io.say("Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.");
284− const until = now() + expiresIn * 1000;
304+ const askWord = asked.asks.length === 1 ? `ask ${asked.asks[0]}` : `asks ${asked.asks.join(", ")}`;
305+ io.say(`Asked ${asked.who} (${askWord} in ${asked.project}) to sign this box in, as at most ${asked.role}.`);
307+ `Waiting for their answer, until ${CENTRAL.format(new Date(asked.expiresAt))} CT. To approve it yourself instead: ${link}`,
312+ io.say("Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.");
314+ const until = asked ? Math.min(asked.expiresAt, now() + MAX_LOGIN_WAIT_S * 1000) : now() + expiresIn * 1000;
290− io.say(`Still waiting for the code ${code} to be approved.`);
@@ -297,8 +331,14 @@
300− if (a.body.error === "access_denied") throw new UsageError(`the code ${code} was turned down.`);
301− throw new UsageError(`the code ${code} ran out. Run abso login again.`);
335+ throw new UsageError(asked ? `${asked.who} turned this sign-in down.` : `the code ${code} was turned down.`);
@@ -308,6 +348,10 @@
353+ throw new UsageError("nobody answered in time, so nothing was granted. Run abso login again.");
313357
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -8,7 +8,7 @@
11−import { boxPublic, boxText, login, loginRequest, logout, readBox } from "./box.ts";
11+import { boxName, boxPublic, boxText, login, loginRequest, logout, originOf, readBox } from "./box.ts";
@@ -45,7 +45,17 @@
48−import { runAck, runAnswer, runAsk, runIssue, runIssues, runReply, runSearch, runWaiting } from "./issues.ts";
4959import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts";
@@ -189,13 +199,15 @@
196− usage: "abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
208+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
198− "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display.",
210+ "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only.",
@@ -203,6 +215,7 @@
207220 say: (line) => process.stderr.write(terminalText(`${line}\n`, colorsPass(process.stderr, env.env))),
@@ -1063,3 +1076,53 @@
1079+
1081+ * abso 684: in an agent's folder on this same server, the ask `abso login` makes of a person in that project, so nobody
1082+ * relays the code. The folder's agent key proves the agent; the device code proves the sign-in is this client's own.
1085+function loginAsk(server: string, env: Env): NonNullable<Parameters<typeof login>[1]["ask"]> | undefined {
1089+ if (config.token === undefined || originOf(config.server) !== originOf(server)) return undefined;
1094+ body: JSON.stringify({ project: config.project, agent: config.agent, device_code: device, user_code: user }),
1103+ if (!asked.ok || !Array.isArray(body.people) || typeof body.request_url !== "string") return null;
1106+ const when = new Intl.DateTimeFormat("en-US", { timeZone: "America/Chicago", hour: "numeric", minute: "2-digit" });
1107+ const question = `Please sign in my box "${boxName()}" for ${config.project}, as at most ${body.role}. It expires at ${when.format(new Date(expiresAt))} CT. Approve or deny: ${body.request_url}`;
1119+ who: body.people.length === 1 ? "the person who approved this agent's box" : `the owners of ${config.project}`,
1124+ for (const id of asks) await api.withdraw(id, { note: "The sign-in ran out; nothing was granted." });
--- a/client/test/box.test.ts
+++ b/client/test/box.test.ts
@@ -458,3 +458,97 @@
461+
462+// abso 684: in an agent's folder, login asks a person in the project instead of relaying the code.
465+ assert.equal(device, started.device_code, "the ask is made with this client's own device code");
477+
478+test("an asked login says who was asked and until when, and doesn't lead with the code (abso 684)", async () => {
488+ [200, { box_id: "b_test", box_token: CREDENTIAL, expires_at: EXPIRES, grant: { projects: [] } }],
500+ /^Asked the person who approved this agent's box \(ask 41 in abso\) to sign this box in, as at most writer\.$/,
502+ assert.match(said[1]!, /^Waiting for their answer, until .* CT\. To approve it yourself instead: /);
505+
529+
530+test("an asked login that nobody answers withdraws its ask and grants nothing (abso 684)", async () => {