fix(rbac): Viewer-Rolle in Settings + Cluster — operative Buttons sperren

Settings: HAProxy-Reload, Render-Configs, Backup-Now, Service-Restart,
E-Mail-Save, Maintenance-Toggle, Backup-/Audit-Retention, Auto-Update-
und IPv6-Toggle disabled für Viewer (Passwort-Änderung bleibt aktiv).
Cluster: Join-Token-Generation, Peer-Removal, mTLS-Cert-Renew disabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-05-24 13:14:51 +02:00
parent 2d027b3044
commit 8b0e8a8ab4
6 changed files with 109 additions and 71 deletions

View File

@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next'
import apiClient, { isEnvelope } from '../../api/client'
import PageHeader from '../../components/PageHeader'
import { useAuthStore } from '../../stores/auth'
const { Text } = Typography
@@ -116,6 +117,7 @@ function useTickingNow(intervalMs = 1000): number {
export default function ClusterPage() {
const { t } = useTranslation()
const now = useTickingNow()
const isViewer = useAuthStore((s) => s.user?.role) === 'viewer'
const { data, isLoading } = useQuery({
queryKey: ['cluster', 'status'],
@@ -246,22 +248,30 @@ export default function ClusterPage() {
{
title: t('common.actions'), key: 'actions', width: 110,
render: (_, r) => (
<Popconfirm
title={t('cluster.removePeerConfirmTitle')}
description={t('cluster.removePeerConfirmDesc', { fqdn: r.fqdn })}
okText={t('common.yes')}
cancelText={t('common.no')}
okButtonProps={{ danger: true }}
onConfirm={() => removePeer.mutate(r.id)}
>
<Button
type="text" size="small" danger
icon={<DeleteOutlined />}
loading={removePeer.isPending && removePeer.variables === r.id}
isViewer ? (
<Tooltip title={t('auth.viewerBadge')}>
<Button type="text" size="small" danger icon={<DeleteOutlined />} disabled>
{t('cluster.removePeerBtn')}
</Button>
</Tooltip>
) : (
<Popconfirm
title={t('cluster.removePeerConfirmTitle')}
description={t('cluster.removePeerConfirmDesc', { fqdn: r.fqdn })}
okText={t('common.yes')}
cancelText={t('common.no')}
okButtonProps={{ danger: true }}
onConfirm={() => removePeer.mutate(r.id)}
>
{t('cluster.removePeerBtn')}
</Button>
</Popconfirm>
<Button
type="text" size="small" danger
icon={<DeleteOutlined />}
loading={removePeer.isPending && removePeer.variables === r.id}
>
{t('cluster.removePeerBtn')}
</Button>
</Popconfirm>
)
),
},
]
@@ -274,13 +284,16 @@ export default function ClusterPage() {
subtitle={t('cluster.intro', { count: 1 + data.peers.length })}
extra={
<Space>
<Button
icon={<KeyOutlined />}
loading={generateToken.isPending}
onClick={() => generateToken.mutate()}
>
{t('cluster.generateJoinToken')}
</Button>
<Tooltip title={isViewer ? t('auth.viewerBadge') : undefined}>
<Button
icon={<KeyOutlined />}
loading={generateToken.isPending}
disabled={isViewer}
onClick={() => generateToken.mutate()}
>
{t('cluster.generateJoinToken')}
</Button>
</Tooltip>
<Tag color={data.mode === 'cluster' ? 'blue' : 'default'}>
{data.mode === 'cluster' ? t('cluster.modeCluster') : t('cluster.modeSingle')}
</Tag>
@@ -363,16 +376,22 @@ export default function ClusterPage() {
{(certStatus.data?.has_ca || certStatus.data?.has_peer) && (
<Card size="small" title={t('cluster.certCardTitle')} className="mb-16"
extra={certStatus.data?.has_ca && (
<Popconfirm
title={t('cluster.renewSelfConfirm')}
okText={t('common.yes')}
cancelText={t('common.no')}
onConfirm={() => renewSelf.mutate()}
>
<Button size="small" loading={renewSelf.isPending}>
{t('cluster.renewSelfBtn')}
</Button>
</Popconfirm>
isViewer ? (
<Tooltip title={t('auth.viewerBadge')}>
<Button size="small" disabled>{t('cluster.renewSelfBtn')}</Button>
</Tooltip>
) : (
<Popconfirm
title={t('cluster.renewSelfConfirm')}
okText={t('common.yes')}
cancelText={t('common.no')}
onConfirm={() => renewSelf.mutate()}
>
<Button size="small" loading={renewSelf.isPending}>
{t('cluster.renewSelfBtn')}
</Button>
</Popconfirm>
)
)}
>
<Descriptions size="small" column={2} bordered>