diff --git a/frontend/src/lib/components/access/NewServiceAccountForm.svelte b/frontend/src/lib/components/access/NewServiceAccountForm.svelte index 8e09d7969b..e469949d73 100644 --- a/frontend/src/lib/components/access/NewServiceAccountForm.svelte +++ b/frontend/src/lib/components/access/NewServiceAccountForm.svelte @@ -221,6 +221,7 @@ {/if} - Created when you deploy, with the access above. Counts as half a seat. + Created when you deploy, with the access above. Until then, tests run as you. Counts as half a + seat. diff --git a/frontend/src/lib/components/access/serviceAccounts.svelte.ts b/frontend/src/lib/components/access/serviceAccounts.svelte.ts index 7ad83e608d..c79f55643c 100644 --- a/frontend/src/lib/components/access/serviceAccounts.svelte.ts +++ b/frontend/src/lib/components/access/serviceAccounts.svelte.ts @@ -28,6 +28,13 @@ export type PendingServiceAccount = { // replaces it with the real one, which only the server's creation knows. export const PENDING_EMAIL_DOMAIN = 'pending.sa.wm.dev' +/** A run-as email for display: the placeholder of an account the deploy creates is not one. */ +export function runAsEmailLabel(email: string | undefined): string | undefined { + return email?.endsWith(`@${PENDING_EMAIL_DOMAIN}`) + ? `${email.split('@')[0]} (created when you deploy)` + : email +} + const pending = new SvelteMap() const key = (workspace: string, permissionedAs: string) => `${workspace}:${permissionedAs}` diff --git a/frontend/src/lib/components/apps/editor/AppPreview.svelte b/frontend/src/lib/components/apps/editor/AppPreview.svelte index a33e26504d..ff620dc868 100644 --- a/frontend/src/lib/components/apps/editor/AppPreview.svelte +++ b/frontend/src/lib/components/apps/editor/AppPreview.svelte @@ -24,6 +24,7 @@ import HiddenComponent from '../components/helpers/HiddenComponent.svelte' import RecomputeAllComponents from './RecomputeAllComponents.svelte' import { BG_PREFIX } from './appUtilsCore' + import { runAsEmailLabel } from '$lib/components/access/serviceAccounts.svelte' interface Props { app: App @@ -301,7 +302,9 @@

{summary}

- {policy.on_behalf_of ? `on behalf of ${policy.on_behalf_of_email}` : ''} + {policy.on_behalf_of + ? `on behalf of ${runAsEmailLabel(policy.on_behalf_of_email)}` + : ''}
diff --git a/frontend/src/lib/components/apps/editor/GridEditor.svelte b/frontend/src/lib/components/apps/editor/GridEditor.svelte index d787564c0c..33ae04df98 100644 --- a/frontend/src/lib/components/apps/editor/GridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/GridEditor.svelte @@ -27,6 +27,7 @@ import Popover from '$lib/components/Popover.svelte' import type { Policy } from '$lib/gen' import { BG_PREFIX, findGridItem } from './appUtilsCore' + import { runAsEmailLabel } from '$lib/components/access/serviceAccounts.svelte' interface Props { policy: Policy @@ -174,7 +175,7 @@ />
- {policy.on_behalf_of ? `Author ${policy.on_behalf_of_email}` : ''} + {policy.on_behalf_of ? `Author ${runAsEmailLabel(policy.on_behalf_of_email)}` : ''} The scripts will be run on behalf of the author and a tight policy ensure security about the possible inputs of the runnables. diff --git a/frontend/src/lib/utils/previewOnBehalfOf.ts b/frontend/src/lib/utils/previewOnBehalfOf.ts index 3b28223b88..0b0fe8f9a6 100644 --- a/frontend/src/lib/utils/previewOnBehalfOf.ts +++ b/frontend/src/lib/utils/previewOnBehalfOf.ts @@ -1,3 +1,5 @@ +import { PENDING_EMAIL_DOMAIN } from '$lib/components/access/serviceAccounts.svelte' + type ActingUser = | { is_admin?: boolean; is_super_admin?: boolean; operator?: boolean; groups?: string[] } | undefined @@ -18,6 +20,8 @@ export function previewOnBehalfOf( !user?.operator && (!!user?.is_admin || !!user?.is_super_admin || !!user?.groups?.includes('wm_deployers')) if (!canPreserve) return undefined + // A service account created at deploy does not exist yet, so the server refuses to run as it. + if (onBehalfOfEmail?.endsWith(`@${PENDING_EMAIL_DOMAIN}`)) return undefined return onBehalfOf || onBehalfOfEmail || undefined }