import m, {MithrilComponent} from '@garage44/mithril' import {Badge, Button, Card, FieldText} from '@garage44/mithril/components' import {who} from '@/components/who' import {act} from '@/lib/actions' import {api} from '@/lib/api' import {age, when} from '@/lib/format' import {makeKey, passkeyHere, signGrant} from '@/lib/passkey' import {bind, local} from '@/lib/reactive' import {$s} from '@/lib/store' import type {AdminRequest} from '@/lib/types' /** * Admin windows (src/admin.rs): a session asks for root on the hub's machine, * and the person's passkey signs the grant — who, for how long, why — which * root checks before sudo works. The hub only carries the signature. */ const rpId = () => $s.admin?.setup?.rp_id ?? location.hostname async function allow(r: AdminRequest) { // Hub's time in the grant: root checks it against its own clock. const s = await api.adminToSign(r.id) const assertion = await signGrant(s.challenge, s.rp_id, s.keys) await api.adminGrant(r.id, s.grant.issued_at, assertion) } /** One request, under Needs you: what for, how long, and Allow (the passkey) or No. */ export function adminRequestRow(r: AdminRequest): m.Children { const blocked = $s.role !== 'admin' ? 'an admin grants root' : passkeyHere(rpId()) return (
{blocked}
: null}
As root there, once: sudo midas hub admin-setup --user agent --rp-id {location.hostname}. The agents then log in as that user, which
is root only in a window you allow.
No passkey yet: until there is one, no session can be given root.
)}{blocked}
: null} {this.s.error ?{this.s.error}
: null} {cmd ? (Made. The machine trusts it only once you install it yourself, as root, from your own login (not a session's): run this there.
{cmd}