fix: contain attended OpenBao login output

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a0290b-3241-74c3-b868-6049545af836
This commit is contained in:
tegwick 2026-08-23 01:31:05 +02:00
parent 461f580813
commit 0fae0904ce
9 changed files with 497 additions and 75 deletions

View file

@ -1169,13 +1169,20 @@ def _access_json(entry, expanded, gate: str, domain: Optional[str]) -> dict:
"ops-warden holds no token."
)
elif expanded.exec_capable:
verb = "fetch" if entry.lane != "login" else "login"
payload["next_action"] = (
f"ops-warden can proxy this {verb} as the caller: "
f"`warden access <need> --fetch`"
+ ("" if entry.lane == "login" else " (or `--exec -- <cmd>`)")
+ f". Runs {entry.owner_repo}'s tool with your identity; ops-warden holds no value."
)
if entry.lane == "login":
payload["next_action"] = (
"Run the attended login and reviewed operation only inside the "
"contained envelope: `warden access <need> --exec -- "
"<reviewed-command>`. The private helper is preflighted, all output "
"is suppressed, and the session is revoked and removed afterward."
)
else:
payload["next_action"] = (
"ops-warden can proxy this fetch as the caller: "
"`warden access <need> --fetch` (or `--exec -- <cmd>`). "
f"Runs {entry.owner_repo}'s tool with your identity; "
"ops-warden holds no value."
)
else:
payload["next_action"] = (
f"obtain from {entry.owner_repo} ({entry.subsystem}); "
@ -1210,6 +1217,7 @@ def _access_proxy(
build_wrapped_fetch,
caller_auth_present,
proxy_exec,
proxy_attended_login_exec,
proxy_fetch,
proxy_fetch_fingerprint,
proxy_fetch_to_file,
@ -1240,18 +1248,17 @@ def _access_proxy(
decision_id = None
if is_login:
# Login lane: interactive auth bootstrap. No caller-auth precheck (you have no
# token yet — that's the point) and no secret-read gate (it needs an identity
# this flow establishes). --exec is meaningless here.
if do_exec:
# Login lane: the authentication and reviewed child command share one
# isolated token-helper home. No credential may persist beyond that child.
if not do_exec or not child_argv:
err.print(
"[red]--exec is not valid for a login lane[/red] "
f"({entry.id!r} is interactive auth). Use --fetch."
"[red]A login lane requires --exec -- <reviewed-command>[/red] "
f"({entry.id!r} cannot create a persistent login-only handoff)."
)
raise typer.Exit(2)
err.print(
"[dim]login lane — interactive auth bootstrap; no secret-read gate, "
"token stays in the caller's own store.[/dim]"
"[dim]login lane — contained OIDC and reviewed command; private helper, "
"suppressed output, deterministic self-revocation.[/dim]"
)
else:
if no_policy:
@ -1343,7 +1350,9 @@ def _access_proxy(
f"(caller identity; value not persisted)[/dim]"
)
try:
if do_exec:
if is_login:
rc = proxy_attended_login_exec(resolved, child_argv=child_argv)
elif do_exec:
if not child_argv:
err.print("[red]--exec needs a command after `--`[/red], e.g. `-- npm publish`.")
raise typer.Exit(2)
@ -1524,8 +1533,13 @@ def access(
console.print(f" auth : {expanded.auth_method}")
if expanded.path_template:
console.print(f" path : {expanded.path_template}")
if expanded.fetch_command:
if expanded.fetch_command and entry.lane != "login":
console.print(f" fetch : {expanded.fetch_command}")
elif expanded.fetch_command:
console.print(
" login : [dim]internal to the contained --exec envelope; "
"do not invoke separately[/dim]"
)
if expanded.policy_ref:
console.print(f" policy : {expanded.policy_ref} [dim]({gate})[/dim]")
console.print(f" wiki : {entry.wiki_ref}")
@ -1544,12 +1558,16 @@ def access(
console.print(f" pointer : [dim]{entry.pointer_command}[/dim]")
if expanded.exec_capable:
label = "fallback" if entry.has_native_exec else "proxy"
hint = (
"transparent conduit — fetches as you"
if entry.lane != "login"
else "runs the interactive login as you"
)
console.print(f" {label:<8} : [dim]{proxy} --fetch[/dim] [yellow]({hint})[/yellow]")
if entry.lane == "login":
console.print(
f" {label:<8} : [dim]{proxy} --exec -- <reviewed-command>[/dim] "
"[yellow](contained login + command; output suppressed)[/yellow]"
)
else:
console.print(
f" {label:<8} : [dim]{proxy} --fetch[/dim] "
"[yellow](transparent conduit — fetches as you)[/yellow]"
)
if expanded.path_template and "<" in expanded.path_template:
console.print(
" note : remaining <…> placeholders are owner-confirmed names "
@ -1564,14 +1582,21 @@ def access(
"conduit (runs the fetch as you, holds nothing)."
)
elif expanded.exec_capable:
verb = "fetch this for you" if entry.lane != "login" else "run this login for you"
console.print(
f"\n[green]ops-warden can {verb}[/green] as the caller — "
f"[bold]{proxy} --fetch[/bold]"
+ ("" if entry.lane == "login" else f" (or [bold]{proxy} --exec -- <cmd>[/bold])")
+ f". It runs {entry.owner_repo}'s tool with [bold]your[/bold] identity; the "
"value streams to you and ops-warden never holds, caches, or logs it."
)
if entry.lane == "login":
console.print(
"\n[green]Contained attended login[/green] — "
f"[bold]{proxy} --exec -- <reviewed-command>[/bold]. The login, "
"command, and revocation use a private helper with suppressed output; "
"the session is removed afterward."
)
else:
console.print(
"\n[green]ops-warden can fetch this for you[/green] as the caller — "
f"[bold]{proxy} --fetch[/bold] (or "
f"[bold]{proxy} --exec -- <cmd>[/bold]). It runs "
f"{entry.owner_repo}'s tool with [bold]your[/bold] identity; the "
"value streams to you and ops-warden never holds, caches, or logs it."
)
else:
console.print(
f"\n[yellow]ops-warden does not hold this secret.[/yellow] "