From cd41d8e070135aa6daf09bbf6e2dff6f855ff64f Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Mon, 2 Nov 2026 00:29:01 -0800 Subject: [PATCH] feat: create service accounts at deploy and check what they can read Co-Authored-By: Claude Opus 5.5 --- .../lib/components/CompareWorkspaces.svelte | 2 + .../src/lib/components/DeployWorkspace.svelte | 2 + .../src/lib/components/FlowBuilder.svelte | 18 +- .../lib/components/OnBehalfOfSelector.svelte | 468 +++++++++++------- .../src/lib/components/ScriptBuilder.svelte | 27 +- .../components/UpdateDevWorkspaceModal.svelte | 2 + .../lib/components/access/ItemReads.svelte | 237 +++++++++ .../access/NewServiceAccountForm.svelte | 226 +++++++++ .../lib/components/access/RunAsNotes.svelte | 182 +++++++ .../src/lib/components/access/detectNeeds.ts | 20 +- .../access/serviceAccounts.svelte.ts | 169 +++++++ .../components/apps/editor/AppEditor.svelte | 6 + .../apps/editor/AppEditorHeader.svelte | 12 +- .../apps/editor/AppSettingsDrawer.svelte | 78 ++- .../components/common/drawer/Drawer.svelte | 6 +- .../flows/content/FlowSettings.svelte | 6 + .../DeployOnBehalfOfDialog.svelte | 42 +- .../DeployOnBehalfOfFields.svelte | 29 +- .../itemSettings/FirstDeployDialog.svelte | 35 +- .../itemSettings/RunOnBehalfOfSetting.svelte | 52 +- .../components/raw_apps/RawAppEditor.svelte | 5 + .../raw_apps/RawAppEditorHeader.svelte | 12 +- .../components/select/SelectDropdown.svelte | 5 +- 23 files changed, 1423 insertions(+), 218 deletions(-) create mode 100644 frontend/src/lib/components/access/ItemReads.svelte create mode 100644 frontend/src/lib/components/access/NewServiceAccountForm.svelte create mode 100644 frontend/src/lib/components/access/RunAsNotes.svelte create mode 100644 frontend/src/lib/components/access/serviceAccounts.svelte.ts diff --git a/frontend/src/lib/components/CompareWorkspaces.svelte b/frontend/src/lib/components/CompareWorkspaces.svelte index 06b691679c..df32b029c8 100644 --- a/frontend/src/lib/components/CompareWorkspaces.svelte +++ b/frontend/src/lib/components/CompareWorkspaces.svelte @@ -1741,6 +1741,8 @@ kind={diff.kind} canPreserve={canPreserveOnBehalfOf} customValue={customOnBehalfOf[key]?.permissionedAs} + size="sm" + class="w-44" /> {/if} {#if diff.kind === 'raw_app'} diff --git a/frontend/src/lib/components/DeployWorkspace.svelte b/frontend/src/lib/components/DeployWorkspace.svelte index 4c7fae7ccd..e62cf66859 100644 --- a/frontend/src/lib/components/DeployWorkspace.svelte +++ b/frontend/src/lib/components/DeployWorkspace.svelte @@ -643,6 +643,8 @@ kind={item.kind} canPreserve={canPreserveOnBehalfOf} customValue={customOnBehalfOf[statusPath]?.permissionedAs} + size="sm" + class="w-44" /> {/if} diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 195189e841..d68469669b 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -1,5 +1,6 @@ +{#snippet statusIcon()} + +{/snippet} + {#if readOnlyWithoutPreserve && !canPreserve} {myDisplayName} {:else} - e.detail && loadUsers()} - > - {#snippet trigger()} - - - {#if selectedDisplayName} - {selectedDisplayName} + + +
+ + {#if selected === 'custom' && isPending(customValue)} + new + {/if} + {#if isFolderDefaultSelected} + + folder default + + {/if} +
+ + {#if offersCreate} + drawerOpen, setDrawerOpen} + size="600px" + minZIndex={aboveConfirmationModal ? 10001 : undefined} + > + setDrawerOpen(false)}> + {#snippet actions()} + + {/snippet} + {#if drawerOpen} + { + onSelect('custom', { + email: `${permissionedAs.slice(2)}@${PENDING_EMAIL_DOMAIN}`, + permissionedAs + }) + setDrawerOpen(false) + }} + /> + {/if} + + + {/if} +{/if} diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index dea378b5e4..d6ee23cffc 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -1,5 +1,6 @@ + + + confirming && grantRead(confirming)} + onCanceled={() => (confirming = undefined)} +> + {#if confirming} +

+ {account} gets read access to the {confirming.kind} + {confirming.path}. The grant applies now, before you deploy. +

+ {/if} +
+ +{#if items.length} +
+ This {kind} needs read access to: + + + + Path + Kind + {#if readable} + {account} + + {/if} + + + + {#each items as item (item.kind + ':' + item.path)} + {@const itemKey = `${item.kind}:${item.path}`} + {@const ok = readable?.(item)} + + {item.path} + {item.kind} + {#if readable} + + {#if grantErrors[itemKey]} + {grantErrors[itemKey]} + {:else if ok} + + + Can read + + {:else} + + + {mode === 'pending' ? "Won't be able to read" : "Can't read"} + + {/if} + + + {#if !ok && mode === 'checked' && isAdmin} + + {/if} + + {/if} + + {/each} + + + {#if shown?.accessError} + Couldn't check {account}'s access: {shown.accessError} + {/if} + {#if mode === 'caller'} + + It runs as whoever runs it, so each of them needs read access to these. + + {/if} + {#if shown?.needs.others.length} + + Also uses {shown.needs.others.map((o) => `${o.kind} ${o.path}`).join(', ')}; access to these + is set on the storage or data table itself. + + {/if} + {#if shown?.needs.errors.length} + + Some of it could not be read, so this list may be incomplete: {shown.needs.errors.join( + '; ' + )}. + + {/if} + + Only paths written out in the code are found; a path the code builds while it runs isn't. + +
+{/if} diff --git a/frontend/src/lib/components/access/NewServiceAccountForm.svelte b/frontend/src/lib/components/access/NewServiceAccountForm.svelte new file mode 100644 index 0000000000..8e09d7969b --- /dev/null +++ b/frontend/src/lib/components/access/NewServiceAccountForm.svelte @@ -0,0 +1,226 @@ + + +
+

+ A service account can't sign in. The {itemKind} runs with only the access you give it here, and keeps + it when people leave. Nothing is created until you deploy. +

+ +
+ Name + + + {nameError ?? `Shown as ${principal} in runs and audit logs.`} + +
+ +
+
+ What it can read + Found in this {itemKind}. Each gets read-only access. +
+ {#if detecting} + + {:else} +
+ {#each rows as row (row.kind + ':' + row.path)} + + {:else} +
+ Nothing found. Add the folders it needs below. +
+ {/each} +
+
+