Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: updater api authorization checks (#2588)
Kyle Mendell8cb524d8d2de
diff --git a/backend/api/handlers/updater.go b/backend/api/handlers/updater.goindex 2452470aa..7f22757ad 100644--- a/backend/api/handlers/updater.go+++ b/backend/api/handlers/updater.go@@ -115,6 +115,9 @@ func RegisterUpdater(api huma.API, updaterService *services.UpdaterService) {// RunUpdater applies pending container updates.func (h *UpdaterHandler) RunUpdater(ctx context.Context, input *RunUpdaterInput) (*RunUpdaterOutput, error) {+ if err := checkAdminInternal(ctx); err != nil {+ return nil, err+ }if h.updaterService == nil {return nil, huma.Error500InternalServerError("service not available")}@@ -179,6 +182,9 @@ func (h *UpdaterHandler) GetUpdaterHistory(ctx context.Context, input *GetUpdate// UpdateContainer updates a single container by pulling the latest image and applying the appropriate update flow.func (h *UpdaterHandler) UpdateContainer(ctx context.Context, input *UpdateContainerInput) (*UpdateContainerOutput, error) {+ if err := checkAdminInternal(ctx); err != nil {+ return nil, err+ }if h.updaterService == nil {return nil, huma.Error500InternalServerError("service not available")}diff --git a/frontend/src/routes/(app)/containers/+page.svelte b/frontend/src/routes/(app)/containers/+page.svelteindex fd35aa9e3..9f12dd71b 100644--- a/frontend/src/routes/(app)/containers/+page.svelte+++ b/frontend/src/routes/(app)/containers/+page.svelte@@ -8,6 +8,8 @@import { untrack } from 'svelte';import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index';import { environmentStore } from '$lib/stores/environment.store.svelte';+ import userStore from '$lib/stores/user-store';+ import { fromStore } from 'svelte/store';import type { ContainerCreateRequest, ContainerStatusCounts } from '$lib/types/container.type';import { createMutation } from '@tanstack/svelte-query';import { BoxIcon } from '$lib/icons';@@ -103,32 +105,39 @@const containerStatusCounts = $derived(containers.counts ?? countsFallback);- const actionButtons: ActionButton[] = $derived([- {- id: 'create',- action: 'create',- label: m.common_create_button({ resource: m.resource_container_cap() }),- onclick: () => (isCreateDialogOpen = true),- loading: createContainerMutation.isPending,- disabled: createContainerMutation.isPending- },- {- id: 'check-updates',- action: 'update',- label: m.containers_check_updates(),- onclick: handleCheckForUpdates,- loading: checkUpdatesMutation.isPending,- disabled: checkUpdatesMutation.isPending- },- {- id: 'refresh',- action: 'restart',- label: m.common_refresh(),- onclick: refresh,- loading: isRefreshing,- disabled: isRefreshing- }- ]);+ const storeUser = fromStore(userStore);+ const isAdmin = $derived(!!storeUser.current?.roles?.includes('admin'));++ const actionButtons: ActionButton[] = $derived(+ [+ {+ id: 'create',+ action: 'create',+ label: m.common_create_button({ resource: m.resource_container_cap() }),+ onclick: () => (isCreateDialogOpen = true),+ loading: createContainerMutation.isPending,+ disabled: createContainerMutation.isPending+ },+ isAdmin+ ? {+ id: 'check-updates',+ action: 'update',+ label: m.containers_check_updates(),+ onclick: handleCheckForUpdates,+ loading: checkUpdatesMutation.isPending,+ disabled: checkUpdatesMutation.isPending+ }+ : null,+ {+ id: 'refresh',+ action: 'restart',+ label: m.common_refresh(),+ onclick: refresh,+ loading: isRefreshing,+ disabled: isRefreshing+ }+ ].filter((b): b is ActionButton => b !== null)+ );const statCards: StatCardConfig[] = $derived([{diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelteindex 4fef769d2..5864992b3 100644--- a/frontend/src/routes/(app)/containers/container-table.svelte+++ b/frontend/src/routes/(app)/containers/container-table.svelte@@ -26,6 +26,8 @@import ContainerStatsSync from './components/container-stats-sync.svelte';import ContainerStatsCell from './components/container-stats-cell.svelte';import { environmentStore } from '$lib/stores/environment.store.svelte';+ import userStore from '$lib/stores/user-store';+ import { fromStore } from 'svelte/store';import IconImage from '$lib/components/icon-image.svelte';import { getArcaneIconUrlFromLabels } from '$lib/utils/arcane-labels';import { createContainerActions } from './container-table.actions';@@ -147,6 +149,9 @@Object.values(actionStatus).some((status) => status !== '') || Object.values(isBulkLoading).some((loading) => loading));+ const storeUser = fromStore(userStore);+ const isAdmin = $derived(!!storeUser.current?.roles?.includes('admin'));+let mobileFieldVisibility = $state<Record<string, boolean>>({});let customSettings = $state<Record<string, unknown>>({});let showInternal = $derived.by(() => {@@ -401,7 +406,7 @@icon={StopIcon}/>{/if}- {#if !status && item.updateInfo?.hasUpdate}+ {#if !status && item.updateInfo?.hasUpdate && isAdmin}<ArcaneButtonaction="base"tone="ghost"@@ -424,7 +429,7 @@imageId={item.imageId}repo={imageRef.repo}tag={imageRef.tag}- onUpdateContainer={() => handleUpdateContainer(item)}+ onUpdateContainer={isAdmin ? () => handleUpdateContainer(item) : undefined}debugHasUpdate={false}/>{/snippet}@@ -566,7 +571,7 @@imageId={item.imageId}repo={imageRef.repo}tag={imageRef.tag}- onUpdateContainer={() => handleUpdateContainer(item)}+ onUpdateContainer={isAdmin ? () => handleUpdateContainer(item) : undefined}debugHasUpdate={false}/></div>@@ -598,7 +603,7 @@<DropdownMenu.Separator />- {#if item.updateInfo?.hasUpdate}+ {#if item.updateInfo?.hasUpdate && isAdmin}<DropdownMenu.Item onclick={() => handleUpdateContainer(item)} disabled={status === 'updating' || isAnyLoading}>{#if status === 'updating'}<Spinner class="size-4" />diff --git a/frontend/src/routes/(app)/updates/container-updates-table.svelte b/frontend/src/routes/(app)/updates/container-updates-table.svelteindex 5faa955a2..a2787160f 100644--- a/frontend/src/routes/(app)/updates/container-updates-table.svelte+++ b/frontend/src/routes/(app)/updates/container-updates-table.svelte@@ -16,6 +16,8 @@} from '$lib/services/container-service';import { ContainersIcon, UpdateIcon } from '$lib/icons';import { getContainerDisplayName } from '../containers/container-table.helpers';+ import userStore from '$lib/stores/user-store';+ import { fromStore } from 'svelte/store';type ContainerUpdateRow = {id: string;@@ -41,6 +43,9 @@let mobileFieldVisibility = $state<MobileFieldVisibility>({});let updatingContainerIds = $state<Record<string, boolean>>({});+ const storeUser = fromStore(userStore);+ const isAdmin = $derived(!!storeUser.current?.roles?.includes('admin'));+function formatUpdateValue(updateInfo: ImageUpdateInfoDto | undefined, mode: 'current' | 'latest') {if (!updateInfo) return '-';@@ -159,15 +164,17 @@{/snippet}{#snippet ActionsCell({ item }: { item: ContainerUpdateRow })}- <ArcaneButton- action="update"- size="sm"- customLabel={m.containers_update_container()}- onclick={() => handleUpdateContainer(item.container)}- loading={!!updatingContainerIds[item.containerId]}- disabled={!!updatingContainerIds[item.containerId]}- icon={UpdateIcon}- />+ {#if isAdmin}+ <ArcaneButton+ action="update"+ size="sm"+ customLabel={m.containers_update_container()}+ onclick={() => handleUpdateContainer(item.container)}+ loading={!!updatingContainerIds[item.containerId]}+ disabled={!!updatingContainerIds[item.containerId]}+ icon={UpdateIcon}+ />+ {/if}{/snippet}{#snippet ContainerUpdatesMobileCard({ item }: { item: ContainerUpdateRow })}