carlos / platform Public

console: carlos apps ttl is owner-only, like Extend (H4 r1)

Review round 1 (Astra P2-7, Fable P2-4): POST /api/cli/apps/{a}/{app}/ttl
took any member or publish credential, while the browser's Extend is
owner-only; a one-hour TTL is a delete by another door now that delete
is owner-only. The door now calls apiOwnerOnly. No passkey step on the
browser side, so none is owed.

TestTTLIsOwnerOnly. New 403 ending: "change when a temporary app
expires" (copy review owed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 6f7b94f8f2889d2a9a123b7c0d511c867d6784cd parent 7adf72c
2 files changed, +26 −0
  • internal/console/apitemporary.go +6 −0
  • internal/console/apitemporary_test.go +20 −0
diff --git a/internal/console/apitemporary.go b/internal/console/apitemporary.go
index c7b5ee775..78d121c39 100644
--- a/internal/console/apitemporary.go
+++ b/internal/console/apitemporary.go
@@ -357,6 +357,12 @@ func (s *Server) handleAPIAppTTL(w http.ResponseWriter, r *http.Request) {
if !ok {
return
}
+ // The browser's Extend is owner-only (handleAppExtend), and a short TTL
+ // is a delete by another door now that delete is owner-only (review
+ // round 1).
+ if !s.apiOwnerOnly(w, r, acct, "change when a temporary app expires") {
+ return
+ }
p, _ := principalFrom(r.Context())
if !s.allowWrite(p, time.Now()) {
jsonError(w, http.StatusTooManyRequests, "too many requests. Wait a minute and try again")
diff --git a/internal/console/apitemporary_test.go b/internal/console/apitemporary_test.go
index 6a1eb5f44..77de3b5b6 100644
--- a/internal/console/apitemporary_test.go
+++ b/internal/console/apitemporary_test.go
@@ -460,3 +460,23 @@ func TestKeepAndTTLRecheckAfterTheLock(t *testing.T) {
}
})
}
+
+// TestTTLIsOwnerOnly (review round 1): the browser's Extend is owner-only,
+// and a one-hour TTL is a delete by another door, so a member's
+// `carlos apps ttl` meets the owner gate's 403 and the expiry stays.
+func TestTTLIsOwnerOnly(t *testing.T) {
+ fx, _ := temporaryFixture(t)
+ exp := time.Now().Add(48 * time.Hour)
+ tempApp(t, fx, "tmp-a", exp)
+ if err := fx.st.AddMember(OpsAccountID, "alice@keymail.dev", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ member := cliToken(t, fx, "alice@keymail.dev", "code-ttl-member")
+ status, out := postJSON(t, appURL(fx, "tmp-a", "/ttl"), map[string]int64{"ttl_seconds": 3600}, member)
+ if status != http.StatusForbidden {
+ t.Fatalf("member ttl = %d %v, want 403", status, out)
+ }
+ if l := lifeOf(t, fx, "tmp-a"); l.ExpiresAt != exp.Unix() {
+ t.Fatalf("expiry after a refused ttl = %d, want %d", l.ExpiresAt, exp.Unix())
+ }
+}