feat(supabase): db:trial grants owner with one verified TOTP factor

Owner decision 2026-11-11: on the trial stack one verified factor suffices
for owner as for admin, a second one optional. The count before the typed
confirmation and the recount inside the grant transaction stay; SQL, aal2
and the rule for every other stack are unchanged.
This commit is contained in:
bchanot committed 2026-11-11 22:37:40 +01:00
1 parent 0573d66864
commit 45d74536f5
4 files changed
+30 -18

No files matched your search

+12 -8
View File
@@ -1210,10 +1210,10 @@ check "account: the body is a confirmed account" stdin_has '"email_confirm":true
check "account: the state folder holds no file that is not 600" bash -c '[ -z "$(find "$1" -type f ! -perm 600)" ]' _ "$STATE_DIR"
fresh_log; trial grant owner@trial.test root
check "grant: an unknown right is refused before any call" refused_early "right:"
set_factors 1
set_factors 0
fresh_stdin; fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner with one factor: refused (two needed), nothing assigned" bash -c '[ "$1" -ne 0 ] && grep -qF "owner needs 2" "$2" && grep -qF "nothing was granted" "$2"' _ "$RC" "$CASE/out"
check "grant owner with one factor: no role SQL ran" no_role_assigned
check "grant owner with no factor: refused (one needed), nothing assigned" bash -c '[ "$1" -ne 0 ] && grep -qF "owner needs 1" "$2" && grep -qF "nothing was granted" "$2"' _ "$RC" "$CASE/out"
check "grant owner with no factor: no role SQL ran" no_role_assigned
set_factors 2
fresh_log; trial_tty no grant owner@trial.test owner
check "grant owner, wrong phrase: nothing assigned" bash -c '[ "$1" -ne 0 ] && grep -qF "not confirmed" "$2"' _ "$RC" "$CASE/out"
@@ -1231,9 +1231,13 @@ check "grant owner: the role SQL failing is told" bash -c '[ "$1" -ne 0 ] && gre
rm -f "$CASE/stub/fail/grant-role"; fresh_stdin
fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner: factors shown, operator path, audit row" bash -c '[ "$1" -eq 0 ] && grep -qF "Tablet | 2026-11-09 10:05 UTC" "$2" && grep -rlF "private.assign_platform_role(null, :'"'"'uid'"'"'::uuid" "$3" | grep -q . && grep -rlF "platform_role.operator_bootstrap" "$3" | grep -q .' _ "$RC" "$CASE/out" "$CASE/stub/stdin"
check "grant owner: email, role and operator as psql variables" log_has "-v email=owner@trial.test -v role=owner -v need=2 -v operator="
check "grant owner: email, role and operator as psql variables" log_has "-v email=owner@trial.test -v role=owner -v need=1 -v operator="
check "grant owner: no secret in calls or output" secrets_absent "$STATE_DIR/secrets.env"
set_factors 1
fresh_stdin; fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner with one factor: granted, one factor suffices" bash -c '[ "$1" -eq 0 ] && grep -qF "owner granted to owner@trial.test" "$2"' _ "$RC" "$CASE/out"
check "grant owner with one factor: need=1 passed as a psql variable" log_has "-v email=owner@trial.test -v role=owner -v need=1 -v operator="
fresh_stdin
fresh_log; trial_tty 'grant admin' grant practitioner@trial.test admin
check "grant admin with one factor: granted, one factor suffices" bash -c '[ "$1" -eq 0 ] && grep -qF "admin granted to practitioner@trial.test" "$2"' _ "$RC" "$CASE/out"
check "grant admin: role passed as a psql variable" log_has "-v email=practitioner@trial.test -v role=admin -v need=1 -v operator="
@@ -1313,13 +1317,13 @@ set_factors 2; fresh_stdin; fresh_log; trial_tty 'grant owner' grant owner@trial
SANITISED="left(regexp_replace(coalesce(nullif(f.friendly_name, ''), '(no name)'), '[^[:alnum:] ._-]', '?', 'g'), 40)"
check "grant: SQL text check, the displayed name is sanitised in SQL (no newline, CR or ESC reaches the terminal)" bash -c 'grep -qF -- "$2" "$1"' _ "$(stdin_of grant-factors)" "$SANITISED"
# 2: the transaction counts again.
echo 1 > "$CASE/stub/answers/txn-factors"; fresh_stdin
echo 0 > "$CASE/stub/answers/txn-factors"; fresh_stdin
fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner: script handling of a failing grant session (stub emulates \\gset with zero rows, count 2 then 1): nothing granted" bash -c '[ "$1" -ne 0 ] && grep -qF "nothing was granted" "$2" && ! grep -qF "owner granted to owner@trial.test" "$2"' _ "$RC" "$CASE/out"
check "grant owner: script handling of a failing grant session (stub emulates \\gset with zero rows, count 2 then 0): nothing granted" bash -c '[ "$1" -ne 0 ] && grep -qF "nothing was granted" "$2" && ! grep -qF "owner granted to owner@trial.test" "$2"' _ "$RC" "$CASE/out"
check "grant owner: the transaction SQL counts the factors against :need" bash -c 'grep -q "mfa_factors" "$1" && grep -q ">= :need" "$1"' _ "$(stdin_of grant-role)"
check "grant role: explicit begin and commit, never --single-transaction" bash -c 'f="$1"; [ "$(sed -n 2p "$f")" = "begin;" ] && [ "$(tail -n 1 "$f")" = "commit;" ] && ! grep -q -- "--single-transaction" "$2"' _ "$(stdin_of grant-role)" "$CASE/log"
echo 2 > "$CASE/stub/answers/txn-factors"; fresh_stdin; fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner: two factors still there in the transaction: granted" bash -c '[ "$1" -eq 0 ] && grep -qF "owner granted to owner@trial.test" "$2"' _ "$RC" "$CASE/out"
echo 1 > "$CASE/stub/answers/txn-factors"; fresh_stdin; fresh_log; trial_tty 'grant owner' grant owner@trial.test owner
check "grant owner: one factor still there in the transaction: granted" bash -c '[ "$1" -eq 0 ] && grep -qF "owner granted to owner@trial.test" "$2"' _ "$RC" "$CASE/out"
rm -f "$CASE/stub/answers/txn-factors"
# 7: the e-mail is lowercased before any use.
fresh_stdin; fresh_log; trial_tty 'grant sheet_reviewer' grant Foo@Example.com sheet_reviewer